Skip to content

Commit 3bb1b82

Browse files
authored
Merge pull request #48 from noti0na1/dotty-explicit-nulls-notNull
Merge upstream Dotty master
2 parents 46fc5cd + 0230180 commit 3bb1b82

File tree

629 files changed

+1080
-15935
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

629 files changed

+1080
-15935
lines changed

bench-run/inputs/tuples/apply.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sizeAndIndex:20 0,20 1,20 2,20 3,20 4,20 5,20 6,20 7,20 8,20 9,20 10,20 11,20 12,20 13,20 14,20 15,20 16,20 17,20 18,20 19

bench-run/inputs/tuples/concat.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sizes:15 0,15 1,15 2,15 3,15 4,15 5,15 6,15 7,15 8,15 9,15 10,15 11,15 12,15 13,15 14,15 15,15 16,15 17,15 18,15 19,15 20,15 21,15 22,15 23,15 24,15 25,15 26,15 27,15 28,15 29,15 30,15 31,15 32,15 33,15 34,15 35,15 36,15 37,15 38,15 39,15 40,15 41,15 42,15 43,15 44,15 45,15 46,15 47,15 48,15 49,15 50

bench-run/inputs/tuples/cons.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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
size: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

bench-run/inputs/tuples/map.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

bench-run/inputs/tuples/tail.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
size: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

bench-run/inputs/tuples/zip.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: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package dotty.tools.benchmarks
2+
3+
import org.openjdk.jmh.results.RunResult
4+
import org.openjdk.jmh.runner.Runner
5+
import org.openjdk.jmh.annotations._
6+
import org.openjdk.jmh.results.format._
7+
import org.openjdk.jmh.runner.options._
8+
import java.util.concurrent.TimeUnit
9+
10+
import scala.io.Source
11+
12+
object Bench {
13+
def main(args: Array[String]): Unit = {
14+
if (args.contains("--help")) {
15+
printUsage()
16+
return
17+
}
18+
19+
val (intArgs, args1) = args.span(x => try { x.toInt; true } catch { case _: Throwable => false } )
20+
21+
def getIntArg(i: Int, default: Int): Int =
22+
if (intArgs.length > i) intArgs(i).toInt else default
23+
24+
val warmup = getIntArg(0, 20)
25+
val iterations = getIntArg(1, 20)
26+
val forks = getIntArg(2, 1)
27+
28+
if (args1.isEmpty) {
29+
println("Error: no benchmark was specified.")
30+
printUsage()
31+
return
32+
}
33+
34+
var builder = new OptionsBuilder()
35+
.shouldFailOnError(true)
36+
.jvmArgs("-Xms2G", "-Xmx2G")
37+
.mode(Mode.AverageTime)
38+
.timeUnit(TimeUnit.NANOSECONDS)
39+
.warmupIterations(warmup)
40+
.warmupTime(TimeValue.milliseconds(750))
41+
.measurementIterations(iterations)
42+
.measurementTime(TimeValue.milliseconds(500))
43+
.forks(forks)
44+
.include(args1(0))
45+
.resultFormat(ResultFormatType.CSV)
46+
47+
if (args1.length > 1 && args1(1) != "--") {
48+
for ((param, values) <- paramsFromFile("inputs/" ++ args1(1)))
49+
builder = builder.param(param, values: _*)
50+
}
51+
52+
if (args1.length > 2) {
53+
builder = builder.result(args1(2))
54+
}
55+
56+
val runner = new Runner(builder.build)
57+
runner.run
58+
}
59+
60+
def paramsFromFile(file: String): Array[(String, Array[String])] = {
61+
Source.fromFile(file).getLines.toArray.map { l =>
62+
val Array(param, values) = l split ':'
63+
(param, values split ',')
64+
}
65+
}
66+
67+
def printUsage(): Unit = {
68+
println()
69+
println("Usage:")
70+
println()
71+
println("dotty-bench-run/jmh:run [<warmup>] [<iterations>] [<forks>] <regexp> [<input>|--] [<output>]")
72+
println()
73+
println("warmup: warmup iterations. defaults to 20.")
74+
println("iterations: benchmark iterations. defaults to 20.")
75+
println("forks: number of forks. defaults to 1.")
76+
println("regexp: regular expression that selects which benchmarks to run.")
77+
println("input: input vector file. each line should have format \'<paramName>: <comma-separated-values>\'")
78+
println("output: output file for the results of benchmarks.")
79+
println()
80+
}
81+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 Apply {
8+
@Param(Array("1 0"))
9+
var sizeAndIndex: String = _
10+
var tuple: NonEmptyTuple = _
11+
var index: Int = _
12+
13+
@Setup
14+
def setup(): Unit = {
15+
val size = sizeAndIndex.split(' ')(0).toInt
16+
index = sizeAndIndex.split(' ')(1).toInt
17+
tuple = "elem" *: ()
18+
19+
for (i <- 1 until size)
20+
tuple = "elem" *: tuple
21+
}
22+
23+
@Benchmark
24+
def tupleApply(): Any = {
25+
DynamicTuple.dynamicApply(tuple, index)
26+
}
27+
28+
@Benchmark
29+
def productElement(): Any = {
30+
tuple.asInstanceOf[Product].productElement(index)
31+
}
32+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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("1"))
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 tupleToArray(): Array[Object] = {
27+
DynamicTuple.dynamicToArray(tuple)
28+
}
29+
30+
@Benchmark
31+
def tupleToIArray(): IArray[Object] = {
32+
DynamicTuple.dynamicToIArray(tuple)
33+
}
34+
35+
@Benchmark
36+
def tupleFromArray(): Tuple = {
37+
DynamicTuple.dynamicFromArray(array)
38+
}
39+
40+
@Benchmark
41+
def tupleFromIArray(): Tuple = {
42+
DynamicTuple.dynamicFromIArray(iarray)
43+
}
44+
45+
@Benchmark
46+
def productToArray(): Array[Object] = {
47+
DynamicTuple.productToArray(tuple.asInstanceOf[Product])
48+
}
49+
50+
@Benchmark
51+
def cloneArray(): Array[Object] = {
52+
array.clone()
53+
}
54+
}

0 commit comments

Comments
 (0)