-
Notifications
You must be signed in to change notification settings - Fork 0
/
Timing.scala
50 lines (40 loc) · 1009 Bytes
/
Timing.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
package demo
import com.fortysevendeg.lambdatest._
import com.fortysevendeg.lambdatesttiming._
import scala.concurrent.duration._
import scala.language.postfixOps
// format: OFF
class Timing extends LambdaTest {
def act = {
def f(t: FiniteDuration) = {
Thread.sleep(t.toMillis)
99
}
timer("all") {
test("Measure") {
assertTiming {
val v = f(50 millis)
assertEq(v, 99, "test eq")
}("this should work", max = 100 millis) +
assertTiming {
exec {
f(100 millis)
}
}("this should fail", max = 75 millis) +
assertTiming {
exec {
f(2 seconds)
}
}("this should timeout", max = 200 millis) +
assertPerf("perfromance test", warmup = 10, repeat = 20, mean = 150 millis, max = 200 millis) {
f(100 millis)
}
}
}
}
}
object Timing {
def main(args: Array[String]): Unit = {
run("measure", new Timing)
}
}