diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 16ba3b23a..78e8d825e 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -52,7 +52,7 @@ jobs: fetch-depth: 0 - uses: olafurpg/setup-scala@v13 with: - java-version: openjdk@1.17.0 + java-version: openjdk@21.0.1=tgz+https://download.java.net/java/GA/jdk21.0.1/415e3f918a1f4062a0074a2794853d0d/12/GPL/openjdk-21.0.1_linux-x64_bin.tar.gz - name: install async-profiler run: | diff --git a/.github/workflows/readme.yml b/.github/workflows/readme.yml deleted file mode 100644 index d85e5bd9a..000000000 --- a/.github/workflows/readme.yml +++ /dev/null @@ -1,15 +0,0 @@ -# name: readme -# on: [push, pull_request] -# jobs: -# readme: -# runs-on: ubuntu-20.04 -# timeout-minutes: 5 -# steps: -# - uses: actions/checkout@v3.0.2 -# with: -# fetch-depth: 0 -# - uses: olafurpg/setup-scala@v13 -# with: -# java-version: openjdk@1.17.0 -# - name: build -# run: sbt "checkReadme" diff --git a/build.sbt b/build.sbt index e53dd3697..470ac92cc 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -val scala3Version = "3.3.0" +val scala3Version = "3.3.1" val scala2Version = "2.13.12" val compilerOptions = Seq( @@ -237,13 +237,15 @@ lazy val `kyo-bench` = .in(file("kyo-bench")) .enablePlugins(JmhPlugin) .dependsOn(`kyo-core-opt` % "test->test;compile->compile") + .dependsOn(`kyo-sttp`) + .dependsOn(`kyo-tapir`) .settings( `kyo-settings`, `without-cross-scala`, - libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.2", - libraryDependencies += "dev.zio" %% "zio" % zioVersion, - libraryDependencies += "dev.zio" %% "zio-concurrent" % zioVersion - // libraryDependencies += "com.softwaremill.ox" %% "core" % "0.0.12" + libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.2", + libraryDependencies += "dev.zio" %% "zio" % zioVersion, + libraryDependencies += "dev.zio" %% "zio-concurrent" % zioVersion, + libraryDependencies += "com.softwaremill.ox" %% "core" % "0.0.14" ) lazy val rewriteReadmeFile = taskKey[Unit]("Rewrite README file") diff --git a/kyo-bench/src/main/scala/kyo/bench/BroadFlatMapBench.scala b/kyo-bench/src/main/scala/kyo/bench/BroadFlatMapBench.scala index 2c03d36bb..b3613e29a 100644 --- a/kyo-bench/src/main/scala/kyo/bench/BroadFlatMapBench.scala +++ b/kyo-bench/src/main/scala/kyo/bench/BroadFlatMapBench.scala @@ -40,20 +40,20 @@ class BroadFlatMapBench extends Bench.SyncAndFork[BigInt] { zioFib(depth) } - // def oxFib(n: Int): BigInt = - // if (n <= 1) n - // else oxFib(n - 1) + oxFib(n - 2) - - // @Benchmark - // def syncOx(): BigInt = { - // oxFib(depth) - // } - - // @Benchmark - // def forkOx(): BigInt = { - // import ox._ - // scoped { - // fork(oxFib(depth)).join() - // } - // } + def oxFib(n: Int): BigInt = + if (n <= 1) n + else oxFib(n - 1) + oxFib(n - 2) + + @Benchmark + def syncOx(): BigInt = { + oxFib(depth) + } + + @Benchmark + def forkOx(): BigInt = { + import ox._ + scoped { + fork(oxFib(depth)).join() + } + } } diff --git a/kyo-bench/src/main/scala/kyo/bench/ChainedForkBench.scala b/kyo-bench/src/main/scala/kyo/bench/ChainedForkBench.scala index 018b597c7..fb170b798 100644 --- a/kyo-bench/src/main/scala/kyo/bench/ChainedForkBench.scala +++ b/kyo-bench/src/main/scala/kyo/bench/ChainedForkBench.scala @@ -75,20 +75,20 @@ class ChainedForkBench extends Bench.ForkOnly[Int] { } yield 0 } - // @Benchmark - // def forkOx() = { - // import ox._ - // def iterate(p: CompletableFuture[Unit], n: Int): Unit = - // if (n <= 0) p.complete(()) - // else - // scoped { - // fork(iterate(p, n - 1)) - // } - - // scoped { - // val p = new CompletableFuture[Unit]() - // fork(iterate(p, depth)) - // p.get() - // } - // } + @Benchmark + def forkOx() = { + import ox._ + def iterate(p: CompletableFuture[Unit], n: Int): Unit = + if (n <= 0) p.complete(()) + else + scoped { + fork(iterate(p, n - 1)) + } + + scoped { + val p = new CompletableFuture[Unit]() + fork(iterate(p, depth)) + p.get() + } + } } diff --git a/kyo-bench/src/main/scala/kyo/bench/ForkManyBench.scala b/kyo-bench/src/main/scala/kyo/bench/ForkManyBench.scala index cd1099b20..85090fdce 100644 --- a/kyo-bench/src/main/scala/kyo/bench/ForkManyBench.scala +++ b/kyo-bench/src/main/scala/kyo/bench/ForkManyBench.scala @@ -78,23 +78,23 @@ class ForkManyBench extends Bench.ForkOnly[Int] { } yield 0 } - // @Benchmark - // def forkOx() = { - // import ox._ - // import ox.channels._ - - // scoped { - // val promise = new CompletableFuture[Unit] - // val ref = new AtomicInteger(depth) - // for (_ <- 0 until depth) { - // fork { - // ref.decrementAndGet() match { - // case 1 => promise.complete(()) - // case _ => () - // } - // } - // } - // promise.get() - // } - // } + @Benchmark + def forkOx() = { + import ox._ + import ox.channels._ + + scoped { + val promise = new CompletableFuture[Unit] + val ref = new AtomicInteger(depth) + for (_ <- 0 until depth) { + fork { + ref.decrementAndGet() match { + case 1 => promise.complete(()) + case _ => () + } + } + } + promise.get() + } + } } diff --git a/kyo-bench/src/main/scala/kyo/bench/ProducerConsumerBench.scala b/kyo-bench/src/main/scala/kyo/bench/ProducerConsumerBench.scala index 849c57e20..9e8f6d227 100644 --- a/kyo-bench/src/main/scala/kyo/bench/ProducerConsumerBench.scala +++ b/kyo-bench/src/main/scala/kyo/bench/ProducerConsumerBench.scala @@ -71,23 +71,23 @@ class ProducerConsumerBench extends Bench.ForkOnly[Unit] { } } - // @Benchmark - // def forkOx() = { - // import ox._ - // import ox.channels._ - - // val q = Channel[Unit](depth / 2) - // scoped { - // val f1 = - // fork { - // for (_ <- 0 until depth) q.send(()).orThrow - // } - // val f2 = - // fork { - // for (_ <- 0 until depth) q.take(1).drain() - // } - // f1.join() - // f2.join() - // } - // } + @Benchmark + def forkOx() = { + import ox._ + import ox.channels._ + + val q = Channel[Unit](depth / 2) + scoped { + val f1 = + fork { + for (_ <- 0 until depth) q.send(()).orThrow + } + val f2 = + fork { + for (_ <- 0 until depth) q.take(1).drain() + } + f1.join() + f2.join() + } + } }