forked from akka/akka
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
=str akka#22448 rewrite Source.empty to GraphStage
- Loading branch information
Showing
6 changed files
with
115 additions
and
10 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
akka-bench-jmh/src/main/scala/akka/stream/EmptySourceBenchmark.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright (C) 2014-2017 Lightbend Inc. <http://www.lightbend.com> | ||
*/ | ||
|
||
package akka.stream | ||
|
||
import java.util.concurrent.TimeUnit | ||
|
||
import akka.actor.ActorSystem | ||
import akka.stream.scaladsl._ | ||
import akka.{ Done, NotUsed } | ||
import org.openjdk.jmh.annotations._ | ||
|
||
import scala.concurrent._ | ||
import scala.concurrent.duration._ | ||
|
||
@State(Scope.Benchmark) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
@BenchmarkMode(Array(Mode.Throughput)) | ||
class EmptySourceBenchmark { | ||
implicit val system = ActorSystem("EmptySourceBenchmark") | ||
val materializerSettings = ActorMaterializerSettings(system).withDispatcher("akka.test.stream-dispatcher") | ||
implicit val materializer = ActorMaterializer(materializerSettings) | ||
|
||
|
||
@TearDown | ||
def shutdown(): Unit = { | ||
Await.result(system.terminate(), 5.seconds) | ||
} | ||
|
||
val setup = Source.empty[String].toMat(Sink.ignore)(Keep.right) | ||
|
||
@Benchmark def empty(): Unit = | ||
Await.result(setup.run(), Duration.Inf) | ||
|
||
|
||
/* | ||
(not serious benchmark, just sanity check: run on macbook 15, late 2013) | ||
While it was a PublisherSource: | ||
[info] EmptySourceBenchmark.empty thrpt 10 11.219 ± 6.498 ops/ms | ||
Rewrite to GraphStage: | ||
[info] EmptySourceBenchmark.empty thrpt 10 17.556 ± 2.865 ops/ms | ||
*/ | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (C) 2009-2017 Lightbend Inc. <http://www.lightbend.com> | ||
*/ | ||
package docs.actor | ||
|
||
import akka.actor.ActorLogging | ||
import scala.language.postfixOps | ||
|
||
import akka.Done | ||
import akka.actor.{ ActorRef, CoordinatedShutdown } | ||
import akka.testkit._ | ||
import akka.util._ | ||
|
||
import scala.concurrent.{ Await, Future } | ||
import scala.concurrent.duration._ | ||
|
||
import akka.actor.ActorSystem | ||
import akka.actor.Actor | ||
import akka.actor.Props | ||
import akka.testkit.{ ImplicitSender, TestKit } | ||
|
||
class LOLSPEC extends AkkaSpec(Map("akka.loglevel" -> "INFO")) { | ||
|
||
"schedule a one-off task" in { | ||
val miku = system.actorOf(Props(new Actor { | ||
def receive = { | ||
case x => | ||
println(s"sender() = ${sender()}") | ||
} | ||
})) | ||
|
||
system.eventStream.subscribe(miku, classOf[Object]) | ||
|
||
system.eventStream.publish("Hello!") | ||
} | ||
|
||
} | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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