Skip to content

Commit

Permalink
Merge pull request scala#2913 from dotty-staging/bench-no-pack
Browse files Browse the repository at this point in the history
Run benchmarks directly from sbt
  • Loading branch information
liufengyun authored Jul 26, 2017
2 parents 7703493 + 007e4fe commit 0ec7e56
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 166 deletions.
2 changes: 2 additions & 0 deletions bench/scripts/collection-strawman.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
find library/src/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench/jmh:run" {} + | sbt
2 changes: 2 additions & 0 deletions bench/scripts/compiler.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
find collection-strawman/src/main/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench/jmh:run" {} + | sbt
2 changes: 2 additions & 0 deletions bench/scripts/library.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
find collection-strawman/src/main/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench/jmh:run" {} + | sbt
25 changes: 16 additions & 9 deletions bench/src/main/scala/Benchmarks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,26 @@ object Bench {
val COMPILE_OPTS_FILE = "compile.txt"

def main(args: Array[String]): Unit = {
storeCompileOptions(args)
if (args.isEmpty) {
println("Missing <args>")
return
}

val libs = System.getenv("BOOTSTRAP_APPEND")
val args2 = args.map { arg =>
if ((arg.endsWith(".scala") || arg.endsWith(".java")) && arg.head != '/') "../" + arg
else arg
}
storeCompileOptions(args2)

val libs = System.getProperty("BENCH_CLASS_PATH")

val opts = new OptionsBuilder()
.jvmArgsPrepend(s"-Xbootclasspath/a:$libs")
.jvmArgsPrepend("-Xbootclasspath/a:" + libs + ":")
.mode(Mode.AverageTime)
.timeUnit(TimeUnit.MICROSECONDS)
.forks(5)
.warmupIterations(5)
.measurementIterations(10)
.resultFormat(ResultFormatType.CSV)
.result("result.csv")
.timeUnit(TimeUnit.MILLISECONDS)
.forks(1)
.warmupIterations(12)
.measurementIterations(20)
.build

val runner = new Runner(opts) // full access to all JMH features, you can also provide a custom output Format here
Expand Down
147 changes: 0 additions & 147 deletions bench/templates/launch.mustache

This file was deleted.

13 changes: 3 additions & 10 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -828,17 +828,10 @@ object Build {
dependsOn(`dotty-compiler`).
settings(commonNonBootstrappedSettings).
settings(
mainClass in (Jmh, run) := Some("dotty.tools.benchmarks.Bench") // custom main for jmh:run
mainClass in (Jmh, run) := Some("dotty.tools.benchmarks.Bench"), // custom main for jmh:run
javaOptions += "-DBENCH_CLASS_PATH=" + Attributed.data((fullClasspath in Compile).value).mkString("", ":", "")
).
enablePlugins(JmhPlugin).
settings(packSettings).
settings(
publishArtifact := false,
packMain := Map("bench" -> "dotty.tools.benchmarks.Bench"),
packGenerateWindowsBatFile := false,
packExpandedClasspath := true,
packBashTemplate := baseDirectory.value + "/templates/launch.mustache"
)
enablePlugins(JmhPlugin)

// Depend on dotty-library so that sbt projects using dotty automatically
// depend on the dotty-library
Expand Down

0 comments on commit 0ec7e56

Please sign in to comment.