Skip to content

Commit 8e20c6f

Browse files
committed
Added benchmark of Catenable
1 parent 673bdd6 commit 8e20c6f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package fs2
2+
package benchmark
3+
4+
import org.openjdk.jmh.annotations.{Benchmark, State, Scope}
5+
6+
import fs2.util.Catenable
7+
8+
@State(Scope.Thread)
9+
class CatenableBenchmark extends BenchmarkUtils {
10+
11+
val smallCatenable = Catenable(1, 2, 3, 4, 5)
12+
val smallVector = Vector(1, 2, 3, 4, 5)
13+
14+
val largeCatenable = Catenable.fromSeq(0 to 1000000)
15+
val largeVector = (0 to 1000000).toVector
16+
17+
@Benchmark def mapSmallCatenable = smallCatenable.map(_ + 1)
18+
@Benchmark def mapSmallVector = smallVector.map(_ + 1)
19+
@Benchmark def mapLargeCatenable = largeCatenable.map(_ + 1)
20+
@Benchmark def mapLargeVector = largeVector.map(_ + 1)
21+
22+
@Benchmark def consSmallCatenable = 0 :: smallCatenable
23+
@Benchmark def consSmallVector = 0 +: smallVector
24+
@Benchmark def consLargeCatenable = 0 :: largeCatenable
25+
@Benchmark def consLargeVector = 0 +: largeVector
26+
27+
@Benchmark def createTinyCatenable = Catenable(1)
28+
@Benchmark def createTinyVector = Vector(1)
29+
@Benchmark def createSmallCatenable = Catenable(1, 2, 3, 4, 5)
30+
@Benchmark def createSmallVector = Vector(1, 2, 3, 4, 5)
31+
}

0 commit comments

Comments
 (0)