Skip to content

Commit dfb8033

Browse files
author
Antoine Brunner
committed
Add benchmarks for tuple split
1 parent 87e5819 commit dfb8033

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

bench-run/inputs/split.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
size:0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 Split {
8+
@Param(Array("0"))
9+
var size: Int = _
10+
var tuple: Tuple = _
11+
var array: Array[Object] = _
12+
var half: Int = _
13+
14+
@Setup
15+
def setup(): Unit = {
16+
tuple = ()
17+
half = size / 2
18+
19+
for (i <- 1 to size)
20+
tuple = "elem" *: tuple
21+
22+
array = new Array[Object](size)
23+
}
24+
25+
@Benchmark
26+
def tupleSplit(): (Tuple, Tuple) = {
27+
DynamicTuple.dynamicSplitAt(tuple, half)
28+
}
29+
30+
@Benchmark
31+
def arraySplit(): (Array[Object], Array[Object]) = {
32+
array.splitAt(half)
33+
}
34+
}

0 commit comments

Comments
 (0)