From 90bb7bc5cc43685723d8b36b20c0dccf5f38628e Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Fri, 8 Sep 2017 17:39:03 +0200 Subject: [PATCH 1/2] Tune bench warmups --- bench/scripts/compiler.sh | 2 +- bench/scripts/library.sh | 2 +- bench/src/main/scala/Benchmarks.scala | 13 ++++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/bench/scripts/compiler.sh b/bench/scripts/compiler.sh index 246ef6bc334d..9612c2459afb 100755 --- a/bench/scripts/compiler.sh +++ b/bench/scripts/compiler.sh @@ -1,2 +1,2 @@ #!/usr/bin/env bash -find compiler/src/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench/jmh:run" {} + | sbt +find compiler/src/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench/jmh:run 5 10" {} + | sbt diff --git a/bench/scripts/library.sh b/bench/scripts/library.sh index 54724bbbd8f2..ef02ea898398 100755 --- a/bench/scripts/library.sh +++ b/bench/scripts/library.sh @@ -1,2 +1,2 @@ #!/usr/bin/env bash -find library/src/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench/jmh:run" {} + | sbt +find library/src/ -type f \( -name "*.scala" -or -name "*.java" \) -exec echo "dotty-bench/jmh:run 40 30" {} + | sbt diff --git a/bench/src/main/scala/Benchmarks.scala b/bench/src/main/scala/Benchmarks.scala index 03e0c2302479..f4695265bcc0 100644 --- a/bench/src/main/scala/Benchmarks.scala +++ b/bench/src/main/scala/Benchmarks.scala @@ -22,8 +22,15 @@ object Bench { println("Missing ") return } + val (intArgs, args1) = args.span(x => try { x.toInt; true } catch { case _: Throwable => false } ) - val args2 = args.map { arg => + var warmup = 30 + var iterations = 20 + + if (intArgs.length > 0) warmup = intArgs(0).toInt + if (intArgs.length > 1) iterations = intArgs(1).toInt + + val args2 = args1.map { arg => if ((arg.endsWith(".scala") || arg.endsWith(".java")) && arg.head != '/') "../" + arg else arg } @@ -36,8 +43,8 @@ object Bench { .mode(Mode.AverageTime) .timeUnit(TimeUnit.MILLISECONDS) .forks(1) - .warmupIterations(30) - .measurementIterations(20) + .warmupIterations(warmup) + .measurementIterations(iterations) .build val runner = new Runner(opts) // full access to all JMH features, you can also provide a custom output Format here From 784dfbf9049b3bea5a00162c0e9eb6495922345c Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Sat, 9 Sep 2017 19:12:44 +0200 Subject: [PATCH 2/2] Valify --- bench/src/main/scala/Benchmarks.scala | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bench/src/main/scala/Benchmarks.scala b/bench/src/main/scala/Benchmarks.scala index f4695265bcc0..608dba8006a1 100644 --- a/bench/src/main/scala/Benchmarks.scala +++ b/bench/src/main/scala/Benchmarks.scala @@ -24,11 +24,8 @@ object Bench { } val (intArgs, args1) = args.span(x => try { x.toInt; true } catch { case _: Throwable => false } ) - var warmup = 30 - var iterations = 20 - - if (intArgs.length > 0) warmup = intArgs(0).toInt - if (intArgs.length > 1) iterations = intArgs(1).toInt + val warmup = if (intArgs.length > 0) intArgs(0).toInt else 30 + val iteration warmup = if (intArgs.length > 1) intArgs(1).toInt else 20 val args2 = args1.map { arg => if ((arg.endsWith(".scala") || arg.endsWith(".java")) && arg.head != '/') "../" + arg