forked from scallop/scallop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoadTest.scala
59 lines (51 loc) · 1.62 KB
/
LoadTest.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package org.rogach.scallop
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import org.rogach.scallop._
import org.rogach.scallop.exceptions._
class LoadTest extends AnyFunSuite with Matchers {
ignore ("trail options") {
val start = System.currentTimeMillis
val opts = Scallop(List("-Ekey1=value1", "key2=value2", "key3=value3"))
.props[String]('E')
.trailArg[String]("first list name")
.trailArg[List[Int]]("first list values")
.trailArg[String]("second list name")
.trailArg[List[Double]]("second list values")
.args(List("first"))
.args((1 to 100).map(_.toString))
.args(List("second"))
.args((1 to 100).map(_.toString))
.verify
val end = System.currentTimeMillis
assert (end - start < 500, "Time bound broken: %d ms" format (end - start))
}
ignore ("retrieving options") {
object Conf extends ScallopConf(List("-a", "1", "-c", "2.0")) {
val apples = opt[Int]("apples")
val carrots = opt[Double]("carrots")
val bananas = 1
verify()
}
def time(fn: => Int) = {
val start = System.currentTimeMillis
var c = 0L
(1 to 1000000).foreach { i =>
c += fn
}
val end = System.currentTimeMillis
end - start
}
val t = time(Conf.apples())
assert(t < 200, "Time bound broken: %d ms" format t)
}
test ("too many options") {
val N = 100000
val opts = List.fill(N)(List("-a","1")).flatten
object Conf extends ScallopConf(opts) {
val apples = opt[List[Int]]("apples")
verify()
}
Conf.apples() should have size (N)
}
}