Skip to content

Instantly share code, notes, and snippets.

@patriknw
Created February 14, 2012 13:10
Show Gist options
  • Save patriknw/1826673 to your computer and use it in GitHub Desktop.
Save patriknw/1826673 to your computer and use it in GitHub Desktop.
TellThroughputPerformanceSpec
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 {
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 math.min(1000L, repeat)) {
actor ! Msg
sent += 1
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment