Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
lib/target/
project/target/
target/
reactive-async.iws
reactive-async.ipr
.idea
*~

.metals/
.bloop/
.bsp/
project/metals.sbt
5 changes: 5 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version = 3.9.4
runner.dialect = scala213

maxColumn = 100
spaces.inImportCurlyBraces = true
45 changes: 19 additions & 26 deletions bench/src/test/scala/com/phaller/rasync/bench/fpbenchmarks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import org.scalameter.picklers.noPickler._

object FuturesAndPromisesBenchmarks extends PerformanceTest.Microbenchmark {
/* configuration */
override def executor = LocalExecutor(
new Executor.Warmer.Default,
Aggregator.min,
new Measurer.Default)
override def executor =
LocalExecutor(new Executor.Warmer.Default, Aggregator.min, new Measurer.Default)
override def reporter = new LoggingReporter
override def persistor = Persistor.None

Expand All @@ -21,42 +19,37 @@ object FuturesAndPromisesBenchmarks extends PerformanceTest.Microbenchmark {
/* creation of promises */
performance of "Promises" in {
measure method "creating" in {
using(size) config (
exec.benchRuns -> 9) in {
r => for (i <- 1 to r) Promise[Int]()
}
using(size) config (exec.benchRuns := 9) in { r =>
for (i <- 1 to r) Promise[Int]()
}
}
}

/* creation and completion of futures */
performance of "Promises" in {
measure method "creating and completing" in {
using(size) config (
exec.benchRuns -> 9) in {
r =>
for (i <- 1 to r) {
val p = Promise[Int]
p.success(1)
}
using(size) config (exec.benchRuns := 9) in { r =>
for (i <- 1 to r) {
val p = Promise[Int]
p.success(1)
}
}
}
}

/* refinement of promises */
performance of "Promises" in {
measure method "refinement" in {
using(Gen.unit(s"$nrOfPromises promises")) config (
exec.benchRuns -> 9) in {
(Unit) =>
{
var i = 0
val promises = createListPromises(nrOfPromises, List.empty)
for (p <- promises) {
i = i + 1
p.success(i)
}
}
using(Gen.unit(s"$nrOfPromises promises")) config (exec.benchRuns := 9) in { (Unit) =>
{
var i = 0
val promises = createListPromises(nrOfPromises, List.empty)
for (p <- promises) {
i = i + 1
p.success(i)
}
}
}
}
}

Expand Down
60 changes: 26 additions & 34 deletions bench/src/test/scala/com/phaller/rasync/bench/rabenchmarks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ import scala.concurrent.duration._

object ReactiveAsyncBenchmarks extends PerformanceTest.Microbenchmark {
/* configuration */
override def executor = LocalExecutor(
new Executor.Warmer.Default,
Aggregator.min,
new Measurer.Default)
override def executor =
LocalExecutor(new Executor.Warmer.Default, Aggregator.min, new Measurer.Default)
override def reporter = new LoggingReporter
override def persistor = Persistor.None

Expand All @@ -30,49 +28,43 @@ object ReactiveAsyncBenchmarks extends PerformanceTest.Microbenchmark {
/* creation of cells/cell completers */
performance of "Cells" in {
measure method "creating" in {
using(size) config (
exec.benchRuns -> 9) in {
r =>
{
implicit val pool = new HandlerPool(NaturalNumberKey, nrOfThreads)
for (i <- 1 to r)
pool.execute(() => { CellCompleter[Int, Null]() }: Unit)
waitUntilQuiescent(pool)
}
using(size) config (exec.benchRuns := 9) in { r =>
{
implicit val pool = new HandlerPool(NaturalNumberKey, nrOfThreads)
for (i <- 1 to r)
pool.execute(() => { CellCompleter[Int, Null]() }: Unit)
waitUntilQuiescent(pool)
}
}
}
}

/* completion of cells */
performance of "Cells" in {
measure method "create and putFinal" in {
using(size) config (
exec.benchRuns -> 9) in {
r =>
{
implicit val pool = new HandlerPool(NaturalNumberKey, nrOfThreads)
for (i <- 1 to r) {
pool.execute(() => {
val cellCompleter = CellCompleter[Int, Null]()
cellCompleter.putFinal(1)
})
}
waitUntilQuiescent(pool)
}
using(size) config (exec.benchRuns := 9) in { r =>
{
implicit val pool = new HandlerPool(NaturalNumberKey, nrOfThreads)
for (i <- 1 to r) {
pool.execute(() => {
val cellCompleter = CellCompleter[Int, Null]()
cellCompleter.putFinal(1)
})
}
waitUntilQuiescent(pool)
}
}
}
}

performance of "Cells" in {
measure method "putNext" in {
using(Gen.unit(s"$nrOfCells cells")) config (
exec.benchRuns -> 9) in {
(Unit) =>
implicit val pool = new HandlerPool(NaturalNumberKey, nrOfThreads)
val cellCompleter = CellCompleter[Int, Null]()
for (i <- 1 to nrOfCells) pool.execute(() => cellCompleter.putNext(i))
waitUntilQuiescent(pool)
}
using(Gen.unit(s"$nrOfCells cells")) config (exec.benchRuns := 9) in { (Unit) =>
implicit val pool = new HandlerPool(NaturalNumberKey, nrOfThreads)
val cellCompleter = CellCompleter[Int, Null]()
for (i <- 1 to nrOfCells) pool.execute(() => cellCompleter.putNext(i))
waitUntilQuiescent(pool)
}
}
}

Expand Down
52 changes: 27 additions & 25 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,59 +1,61 @@
import Dependencies._ // see project/Dependencies.scala
import Util._ // see project/Util.scala
import Version._ // see project/Version.scala

val buildVersion = "0.2.1-SNAPSHOT"
organization in ThisBuild := "com.phaller"
licenses in ThisBuild += ("BSD 2-Clause", url("http://opensource.org/licenses/BSD-2-Clause"))
val buildVersion = "0.2.2-SNAPSHOT"
ThisBuild / organization := "com.phaller"
ThisBuild / licenses += ("BSD 2-Clause", url("http://opensource.org/licenses/BSD-2-Clause"))

def commonSettings = Seq(
version in ThisBuild := buildVersion,
ThisBuild / version := buildVersion,
scalaVersion := buildScalaVersion,
logBuffered := false,
parallelExecution in Test := false,
resolvers in ThisBuild += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
Test / parallelExecution := false,
ThisBuild / resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
)

def noPublish = Seq(
publish := {},
publishLocal := {}
)

lazy val core: Project = (project in file("core")).
settings(commonSettings: _*).
settings(
lazy val core: Project = (project in file("core"))
.settings(commonSettings: _*)
.settings(
name := "reactive-async",
libraryDependencies += scalaTest,
libraryDependencies += opalCommon,
libraryDependencies += opalTAC,
scalacOptions += "-feature"
)

lazy val npv: Project = (project in file("monte-carlo-npv")).
settings(commonSettings: _*).
settings(
lazy val npv: Project = (project in file("monte-carlo-npv"))
.settings(commonSettings: _*)
.settings(
name := "reactive-async-npv",
scalacOptions += "-feature",
skip in publish := true
).
dependsOn(core)
publish / skip := true
)
.dependsOn(core)

lazy val Benchmark = config("bench") extend Test

lazy val bench: Project = (project in file("bench")).
settings(commonSettings: _*).
settings(
lazy val bench: Project = (project in file("bench"))
.settings(commonSettings: _*)
.settings(
name := "reactive-async-bench",
libraryDependencies += scalaTest,
libraryDependencies += opalCommon,
// libraryDependencies += opalAI % Test,
libraryDependencies += scalaMeter,
testFrameworks += new TestFramework("org.scalameter.ScalaMeterFramework"),
skip in publish := true
).configs(
publish / skip := true
)
.configs(
Benchmark
).settings(
)
.settings(
inConfig(Benchmark)(Defaults.testSettings): _*
).
dependsOn(core)
)
.dependsOn(core)

javaOptions in ThisBuild ++= Seq("-Xmx27G", "-Xms1024m", "-XX:ThreadStackSize=2048")
ThisBuild / javaOptions ++= Seq("-Xmx27G", "-Xms1024m", "-XX:ThreadStackSize=2048")
Loading