|
Akka/Scala example source code file (AddressTerminatedTopicBenchSpec.scala)
The AddressTerminatedTopicBenchSpec.scala Akka example source code/** * Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com> */ package akka.event import scala.concurrent.duration._ import akka.actor.Actor import akka.actor.ActorRef import akka.actor.ActorSystem import akka.actor.Address import akka.actor.Props import akka.testkit._ object AddressTerminatedTopicBenchSpec { class Subscriber(testActor: ActorRef) extends Actor { AddressTerminatedTopic(context.system).subscribe(self) testActor ! "started" override def postStop(): Unit = { AddressTerminatedTopic(context.system).unsubscribe(self) } def receive = Actor.emptyBehavior } } @org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner]) class AddressTerminatedTopicBenchSpec extends AkkaSpec("akka.loglevel=INFO") { import AddressTerminatedTopicBenchSpec._ "Subscribe and unsubscribe of AddressTerminated" must { "be quick" in { val sys = ActorSystem(system.name + "2", system.settings.config) try { val num = 20000 val t1 = System.nanoTime() val p = Props(classOf[Subscriber], testActor) val subscribers = Vector.fill(num)(sys.actorOf(p)) receiveN(num, 10.seconds) log.info("Starting {} actors took {} ms", num, (System.nanoTime() - t1).nanos.toMillis) val t2 = System.nanoTime() shutdown(sys, 10.seconds, verifySystemShutdown = true) log.info("Stopping {} actors took {} ms", num, (System.nanoTime() - t2).nanos.toMillis) } finally { if (!sys.isTerminated) shutdown(sys) } } } } Other Akka source code examplesHere is a short list of links related to this Akka AddressTerminatedTopicBenchSpec.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.