File tree Expand file tree Collapse file tree 5 files changed +91
-3
lines changed Expand file tree Collapse file tree 5 files changed +91
-3
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import org.openjdk.jmh.annotations._
44import scala .runtime .DynamicTuple
55
66@ State (Scope .Thread )
7- class ApplyBenchmarks {
7+ class Apply {
88 @ Param (Array (" 1 0" ))
99 var sizeAndIndex : String = _
1010 var tuple : NonEmptyTuple = _
@@ -17,7 +17,7 @@ class ApplyBenchmarks {
1717 tuple = " elem" *: ()
1818
1919 for (i <- 1 until size)
20- tuple = " string " *: tuple
20+ tuple = " elem " *: tuple
2121 }
2222
2323 @ Benchmark
Original file line number Diff line number Diff line change 1+ package dotty .tools .benchmarks .tuples
2+
3+ import org .openjdk .jmh .annotations ._
4+ import scala .runtime .DynamicTuple
5+
6+ @ State (Scope .Thread )
7+ class ArrayOps {
8+ @ Param (Array (" 0" ))
9+ var size : Int = _
10+ var tuple : Tuple = _
11+ var array : Array [Object ] = _
12+ var iarray : IArray [Object ] = _
13+
14+ @ Setup
15+ def setup (): Unit = {
16+ tuple = ()
17+
18+ for (i <- 1 to size)
19+ tuple = " elem" *: tuple
20+
21+ array = Array .fill(size)(" elem" )
22+ iarray = IArray .fill(size)(" elem" )
23+ }
24+
25+ @ Benchmark
26+ def baseline (): Unit = {}
27+
28+ @ Benchmark
29+ def toArray (): Array [Object ] = {
30+ DynamicTuple .dynamicToArray(tuple)
31+ }
32+
33+ @ Benchmark
34+ def toIArray (): IArray [Object ] = {
35+ DynamicTuple .dynamicToIArray(tuple)
36+ }
37+
38+ @ Benchmark
39+ def fromArray (): Tuple = {
40+ DynamicTuple .dynamicFromArray(array)
41+ }
42+
43+ @ Benchmark
44+ def fromIArray (): Tuple = {
45+ DynamicTuple .dynamicFromIArray(iarray)
46+ }
47+ }
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ class Concat {
2525 val size1 = sizes.split(' ' )(0 ).toInt
2626 val size2 = sizes.split(' ' )(1 ).toInt
2727 tuple1 = tupleOfSize(size1)
28- tuple1 = tupleOfSize(size2)
28+ tuple2 = tupleOfSize(size2)
2929 array1 = Array .fill(size1)(" elem" )
3030 array2 = Array .fill(size2)(" elem" )
3131 }
Original file line number Diff line number Diff line change 1+ package dotty .tools .benchmarks .tuples
2+
3+ import org .openjdk .jmh .annotations ._
4+ import scala .runtime .DynamicTuple
5+
6+ @ State (Scope .Thread )
7+ class Cons {
8+ @ Param (Array (" 0" ))
9+ var size : Int = _
10+ var tuple : Tuple = _
11+ var array : Array [Object ] = _
12+
13+ @ Setup
14+ def setup (): Unit = {
15+ tuple = ()
16+
17+ for (i <- 1 to size)
18+ tuple = " elem" *: tuple
19+
20+ array = Array .fill(size)(" elem" )
21+ }
22+
23+ @ Benchmark
24+ def baseline (): Unit = {}
25+
26+ @ Benchmark
27+ def normal (): Tuple = {
28+ " elem" *: tuple
29+ }
30+
31+ @ Benchmark
32+ def inlined (): Tuple = {
33+ DynamicTuple .dynamicCons(" elem" , tuple)
34+ }
35+
36+ // This part is here to measure the performance of dong a cons on arrays directly
37+ @ Benchmark
38+ def arrayCons (): Array [Object ] = {
39+ DynamicTuple .cons$Array (" elem" , array)
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments