Skip to content

Commit 0ec7e56

Browse files
authored
Merge pull request #2913 from dotty-staging/bench-no-pack
Run benchmarks directly from sbt
2 parents 7703493 + 007e4fe commit 0ec7e56

File tree

6 files changed

+25
-166
lines changed

6 files changed

+25
-166
lines changed

bench/scripts/collection-strawman.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env bash
2+
find library/src/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench/jmh:run" {} + | sbt

bench/scripts/compiler.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env bash
2+
find collection-strawman/src/main/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench/jmh:run" {} + | sbt

bench/scripts/library.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env bash
2+
find collection-strawman/src/main/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench/jmh:run" {} + | sbt

bench/src/main/scala/Benchmarks.scala

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,26 @@ object Bench {
1818
val COMPILE_OPTS_FILE = "compile.txt"
1919

2020
def main(args: Array[String]): Unit = {
21-
storeCompileOptions(args)
21+
if (args.isEmpty) {
22+
println("Missing <args>")
23+
return
24+
}
2225

23-
val libs = System.getenv("BOOTSTRAP_APPEND")
26+
val args2 = args.map { arg =>
27+
if ((arg.endsWith(".scala") || arg.endsWith(".java")) && arg.head != '/') "../" + arg
28+
else arg
29+
}
30+
storeCompileOptions(args2)
31+
32+
val libs = System.getProperty("BENCH_CLASS_PATH")
2433

2534
val opts = new OptionsBuilder()
26-
.jvmArgsPrepend(s"-Xbootclasspath/a:$libs")
35+
.jvmArgsPrepend("-Xbootclasspath/a:" + libs + ":")
2736
.mode(Mode.AverageTime)
28-
.timeUnit(TimeUnit.MICROSECONDS)
29-
.forks(5)
30-
.warmupIterations(5)
31-
.measurementIterations(10)
32-
.resultFormat(ResultFormatType.CSV)
33-
.result("result.csv")
37+
.timeUnit(TimeUnit.MILLISECONDS)
38+
.forks(1)
39+
.warmupIterations(12)
40+
.measurementIterations(20)
3441
.build
3542

3643
val runner = new Runner(opts) // full access to all JMH features, you can also provide a custom output Format here

bench/templates/launch.mustache

Lines changed: 0 additions & 147 deletions
This file was deleted.

project/Build.scala

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -828,17 +828,10 @@ object Build {
828828
dependsOn(`dotty-compiler`).
829829
settings(commonNonBootstrappedSettings).
830830
settings(
831-
mainClass in (Jmh, run) := Some("dotty.tools.benchmarks.Bench") // custom main for jmh:run
831+
mainClass in (Jmh, run) := Some("dotty.tools.benchmarks.Bench"), // custom main for jmh:run
832+
javaOptions += "-DBENCH_CLASS_PATH=" + Attributed.data((fullClasspath in Compile).value).mkString("", ":", "")
832833
).
833-
enablePlugins(JmhPlugin).
834-
settings(packSettings).
835-
settings(
836-
publishArtifact := false,
837-
packMain := Map("bench" -> "dotty.tools.benchmarks.Bench"),
838-
packGenerateWindowsBatFile := false,
839-
packExpandedClasspath := true,
840-
packBashTemplate := baseDirectory.value + "/templates/launch.mustache"
841-
)
834+
enablePlugins(JmhPlugin)
842835

843836
// Depend on dotty-library so that sbt projects using dotty automatically
844837
// depend on the dotty-library

0 commit comments

Comments
 (0)