Forked from patriknw/TellThroughputPerformanceSpec2.scala
Last active
August 29, 2015 14:21
-
-
Save iamthiago/4a8ed22720b6c53ba90e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case object Run | |
case object Msg | |
class Destination extends Actor { | |
def receive = { | |
case Msg ⇒ sender ! Msg | |
} | |
} | |
class Client( | |
actor: ActorRef, | |
latch: CountDownLatch, | |
repeat: Long) extends Actor { | |
val initalMessages = math.min( | |
repeat, | |
2 * context.system.settings.config.getInt( | |
"benchmark.throughput-dispatcher.throughput")) | |
var sent = 0L | |
var received = 0L | |
def receive = { | |
case Msg ⇒ | |
received += 1 | |
if (sent < repeat) { | |
actor ! Msg | |
sent += 1 | |
} else if (received >= repeat) { | |
latch.countDown() | |
} | |
case Run ⇒ | |
for (i ← 0L until initalMessages) { | |
actor ! Msg | |
sent += 1 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment