-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestHarness.scala
40 lines (32 loc) · 1 KB
/
TestHarness.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
package rings
import scala.concurrent.duration._
import scala.concurrent.Await
import akka.actor.{Actor, ActorSystem, ActorRef, Props}
import akka.event.Logging
import akka.pattern.ask
import akka.util.Timeout
object TestHarness {
val numNodes = 5
val burstSize = 1
val opsPerNode = 1000
val system = ActorSystem("Rings")
val t = 5
implicit val timeout = Timeout(120 seconds)
// Service tier: create app servers and a Seq of per-node Stats
val master = KVAppService(system, numNodes, burstSize, t)
def main(args: Array[String]): Unit = run()
def run(): Unit = {
val s = System.currentTimeMillis
runUntilDone
val runtime = System.currentTimeMillis - s
val throughput = (opsPerNode * numNodes)/runtime
println(s"Done in $runtime ms ($throughput Kops/sec)")
system.shutdown()
}
def runUntilDone() = {
val future = ask(master, Join()).mapTo[Stats]
master ! Start(opsPerNode)
val done = Await.result(future, 120 seconds)
println(s"Final stats: $done")
}
}