Added sampling of latency measurement
This commit is contained in:
parent
045b9d96c6
commit
963ea0d9b2
2 changed files with 29 additions and 16 deletions
|
|
@ -37,7 +37,7 @@ abstract class AkkaPerformanceTest extends BenchmarkScenarios {
|
|||
val start = System.nanoTime
|
||||
val clients = (for (i ← 0 until numberOfClients) yield {
|
||||
val receiver = receivers(i % receivers.size)
|
||||
Props(new Client(receiver, orders, latch, repeatsPerClient + (if (i < oddRepeats) 1 else 0), delayMs)).withDispatcher(clientDispatcher)
|
||||
Props(new Client(receiver, orders, latch, repeatsPerClient + (if (i < oddRepeats) 1 else 0), sampling, delayMs)).withDispatcher(clientDispatcher)
|
||||
}).toList.map(actorOf(_))
|
||||
|
||||
clients.foreach(_ ! "run")
|
||||
|
|
@ -50,28 +50,35 @@ abstract class AkkaPerformanceTest extends BenchmarkScenarios {
|
|||
clients.foreach(_ ! PoisonPill)
|
||||
}
|
||||
|
||||
class Client(orderReceiver: ActorRef, orders: List[Order], latch: CountDownLatch, repeat: Int, delayMs: Int) extends Actor {
|
||||
def this(orderReceiver: ActorRef, orders: List[Order], latch: CountDownLatch, repeat: Int) {
|
||||
this(orderReceiver, orders, latch, repeat, 0)
|
||||
}
|
||||
class Client(
|
||||
orderReceiver: ActorRef,
|
||||
orders: List[Order],
|
||||
latch: CountDownLatch,
|
||||
repeat: Int,
|
||||
sampling: Int,
|
||||
delayMs: Int = 0) extends Actor {
|
||||
|
||||
def receive = {
|
||||
case "run" ⇒
|
||||
(1 to repeat).foreach(i ⇒
|
||||
{
|
||||
for (o ← orders) {
|
||||
var n = 0
|
||||
for (r ← 1 to repeat; o ← orders) {
|
||||
n += 1
|
||||
val rsp =
|
||||
if (n % sampling == 0) {
|
||||
val t0 = System.nanoTime
|
||||
val rsp = placeOrder(orderReceiver, o)
|
||||
val duration = System.nanoTime - t0
|
||||
stat.addValue(duration)
|
||||
if (!rsp.status) {
|
||||
EventHandler.error(this, "Invalid rsp")
|
||||
}
|
||||
delay(delayMs)
|
||||
rsp
|
||||
} else {
|
||||
placeOrder(orderReceiver, o)
|
||||
}
|
||||
})
|
||||
if (!rsp.status) {
|
||||
EventHandler.error(this, "Invalid rsp")
|
||||
}
|
||||
delay(delayMs)
|
||||
}
|
||||
latch.countDown()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,10 @@ trait PerformanceTest extends JUnitSuite {
|
|||
System.getProperty("benchmark.timeDilation", "1").toLong
|
||||
}
|
||||
|
||||
def sampling = {
|
||||
System.getProperty("benchmark.sampling", "100").toInt
|
||||
}
|
||||
|
||||
var stat: DescriptiveStatistics = _
|
||||
|
||||
val resultRepository = BenchResultRepository()
|
||||
|
|
@ -113,16 +117,18 @@ trait PerformanceTest extends JUnitSuite {
|
|||
75 -> (stat.getPercentile(75.0) / 1000).toLong,
|
||||
95 -> (stat.getPercentile(95.0) / 1000).toLong)
|
||||
|
||||
val n = stat.getN * sampling
|
||||
|
||||
val stats = Stats(
|
||||
name,
|
||||
load = numberOfClients,
|
||||
timestamp = TestStart.startTime,
|
||||
durationNanos = durationNs,
|
||||
n = stat.getN,
|
||||
n = n,
|
||||
min = (stat.getMin / 1000).toLong,
|
||||
max = (stat.getMax / 1000).toLong,
|
||||
mean = (stat.getMean / 1000).toLong,
|
||||
tps = (stat.getN.toDouble / durationS),
|
||||
tps = (n.toDouble / durationS),
|
||||
percentiles)
|
||||
|
||||
resultRepository.add(stats)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue