Skip to content

Run benchmarks directly from sbt #2913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please print the entire command line that was used to launch the behcnmark vm?

Copy link
Contributor Author

@nicolasstucki nicolasstucki Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liufengyun do you know if that is possible without the jmh plugin?

Copy link
Contributor

@liufengyun liufengyun Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the command runs, we'll have the output in the console, which shows the VM options:

# JMH 1.18 (released 134 days ago)
# VM version: JDK 1.8.0_131, VM 25.131-b11
# VM invoker: /usr/lib/jvm/java-8-oracle/jre/bin/java
# VM options: -Xbootclasspath/a:some/jars
# Warmup: 10 iterations, 1 s each
# Measurement: 20 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: dotty.tools.benchmarks.Worker.compile

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