Skip to content

Commit

Permalink
Updated StreamBenchmark to include Rapid Parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
darkfrog26 committed Dec 12, 2024
1 parent 18798a3 commit b1f234a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions benchmark/src/main/scala/benchmark/StreamBenchmark.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class StreamBenchmark {
verify(rapidStream.toList.sync())
}

@Benchmark
def rapidParallelStreamToList(): List[Int] = {
verify(rapidStream.par()(Task.pure).toList.sync())
}

@Benchmark
def fs2StreamToList(): List[Int] = {
verify(fs2Stream.compile.toList.unsafeRunSync())
Expand All @@ -46,6 +51,11 @@ class StreamBenchmark {
verify(rapidStream.filter(_ % 2 == 0).toList.sync(), size / 2)
}

@Benchmark
def rapidParallelStreamFilter(): List[Int] = {
verify(rapidStream.filter(_ % 2 == 0).par()(Task.pure).toList.sync(), size / 2)
}

@Benchmark
def fs2StreamFilter(): List[Int] = {
verify(fs2Stream.filter(_ % 2 == 0).compile.toList.unsafeRunSync(), size / 2)
Expand All @@ -56,6 +66,11 @@ class StreamBenchmark {
verify(rapidStream.map(_ * 2).toList.sync())
}

@Benchmark
def rapidParallelStreamMap(): List[Int] = {
verify(rapidStream.par()(i => Task(i * 2)).toList.sync())
}

@Benchmark
def fs2StreamMap(): List[Int] = {
verify(fs2Stream.map(_ * 2).compile.toList.unsafeRunSync())
Expand Down

0 comments on commit b1f234a

Please sign in to comment.