diff --git a/build.sbt b/build.sbt index 97ee9ad..90b6262 100644 --- a/build.sbt +++ b/build.sbt @@ -5,9 +5,10 @@ name := "compiler-benchmark" version := "1.0-SNAPSHOT" -def scala211 = "2.11.11" -def dottyLatest = "0.2.0-RC1" -scalaVersion in ThisBuild := scala211 +def scala212 = "2.12.6" +def dottyLatest = "0.8.0-RC1" +scalaVersion in ThisBuild := scala212 +val JmhConfig = config("jmh") commands += Command.command("testAll") { s => "test:compile" :: @@ -16,7 +17,7 @@ commands += Command.command("testAll") { s => s"++$dottyLatest" :: "compilation/test" :: "hot -psource=vector -wi 1 -i 1 -f1" :: - s"++$scala211" :: + s"++$scala212" :: "micro/jmh:run -w1 -f1" :: s } @@ -57,7 +58,7 @@ lazy val compilation = addJmh(project).settings( if (isDotty.value) "ch.epfl.lamp" %% "dotty-compiler" % scalaVersion.value else scalaOrganization.value % "scala-compiler" % scalaVersion.value }, - crossScalaVersions := List(scala211, dottyLatest), + crossScalaVersions := List(scala212, dottyLatest), unmanagedSourceDirectories.in(Compile) += sourceDirectory.in(Compile).value / (if (isDotty.value) "dotc" else "scalac"), mainClass in (Jmh, run) := Some("scala.bench.ScalacBenchmarkRunner"), @@ -122,13 +123,14 @@ commands += Command.arb(profParser)((s: State, line: String) => { def command(outDir: File): String = "-prof perfnorm" } - val profs = List(perfNorm, basic, async, jfr) + val profs = List(jfr, perfNorm, basic, async) val commands: List[String] = profs.flatMap { (prof: Profiler) => val outDir = file(s"target/profile-${prof.name}") IO.createDirectory(outDir) List(line + " -jvmArgs -Dsun.reflect.inflationThreshold=0 " + prof.command(outDir) + s" -o ${(outDir / "jmh.log").getAbsolutePath} -rf json -rff ${(outDir / "result.json").getAbsolutePath}", BasicCommandStrings.FailureWall) } - s.copy(remainingCommands = BasicCommandStrings.ClearOnFailure :: commands ++ s.remainingCommands) + val remainingCommands1 = (BasicCommandStrings.ClearOnFailure :: commands).map(s => Exec(s, None)) ++ s.remainingCommands + s.copy(remainingCommands = remainingCommands1) }) @@ -136,5 +138,5 @@ def addJmh(project: Project): Project = { // IntelliJ SBT project import doesn't like sbt-jmh's default setup, which results the prod and test // output paths overlapping. This is because sbt-jmh declares the `jmh` config as extending `test`, but // configures `classDirectory in Jmh := classDirectory in Compile`. - project.enablePlugins(JmhPlugin).overrideConfigs(config("jmh").extend(Compile)) + project.enablePlugins(JmhPlugin).overrideConfigs(JmhConfig.extend(Compile)) } diff --git a/compilation/src/main/dotc/scala/tools/benchmark/BenchmarkDriver.scala b/compilation/src/main/dotc/scala/tools/benchmark/BenchmarkDriver.scala index 632210d..2793d04 100644 --- a/compilation/src/main/dotc/scala/tools/benchmark/BenchmarkDriver.scala +++ b/compilation/src/main/dotc/scala/tools/benchmark/BenchmarkDriver.scala @@ -13,7 +13,7 @@ trait BenchmarkDriver extends BaseBenchmarkDriver { depsClasspath.mkString(File.pathSeparator)) } ctx.setSetting(ctx.settings.migration, false) - ctx.setSetting(ctx.settings.d, tempDir.getAbsolutePath) + ctx.setSetting(ctx.settings.outputDir, tempDir.getAbsolutePath) ctx.setSetting(ctx.settings.language, List("Scala2")) val compiler = new dotty.tools.dotc.Compiler val reporter = dotty.tools.dotc.Bench.doCompile(compiler, allArgs) diff --git a/compilation/src/main/scala/scala/tools/nsc/HotSbtBenchmark.scala b/compilation/src/main/scala/scala/tools/nsc/HotSbtBenchmark.scala index 102cafb..ba77ba1 100644 --- a/compilation/src/main/scala/scala/tools/nsc/HotSbtBenchmark.scala +++ b/compilation/src/main/scala/scala/tools/nsc/HotSbtBenchmark.scala @@ -4,11 +4,11 @@ import java.io._ import java.nio.file._ import java.util.concurrent.TimeUnit -import org.openjdk.jmh.annotations.Mode.SampleTime +import org.openjdk.jmh.annotations.Mode import org.openjdk.jmh.annotations._ @State(Scope.Benchmark) -@BenchmarkMode(Array(SampleTime)) +@BenchmarkMode(Array(org.openjdk.jmh.annotations.Mode.SampleTime)) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Warmup(iterations = 10, time = 10, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 10, time = 10, timeUnit = TimeUnit.SECONDS) diff --git a/compilation/src/main/scala/scala/tools/nsc/ScalacBenchmark.scala b/compilation/src/main/scala/scala/tools/nsc/ScalacBenchmark.scala index 3d1548f..d527f51 100644 --- a/compilation/src/main/scala/scala/tools/nsc/ScalacBenchmark.scala +++ b/compilation/src/main/scala/scala/tools/nsc/ScalacBenchmark.scala @@ -111,7 +111,7 @@ object ScalacBenchmarkStandalone { } @State(Scope.Benchmark) -@BenchmarkMode(Array(SingleShotTime)) +@BenchmarkMode(Array(org.openjdk.jmh.annotations.Mode.SingleShotTime)) @OutputTimeUnit(TimeUnit.MILLISECONDS) // TODO -Xbatch reduces fork-to-fork variance, but incurs 5s -> 30s slowdown @Fork(value = 16, jvmArgs = Array("-XX:CICompilerCount=2", "-Xms2G", "-Xmx2G")) @@ -120,7 +120,7 @@ class ColdScalacBenchmark extends ScalacBenchmark { def compile(): Unit = compileImpl() } -@BenchmarkMode(Array(SampleTime)) +@BenchmarkMode(Array(org.openjdk.jmh.annotations.Mode.SampleTime)) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 30, timeUnit = TimeUnit.SECONDS) @@ -130,7 +130,7 @@ class WarmScalacBenchmark extends ScalacBenchmark { def compile(): Unit = compileImpl() } -@BenchmarkMode(Array(SampleTime)) +@BenchmarkMode(Array(org.openjdk.jmh.annotations.Mode.SampleTime)) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Warmup(iterations = 10, time = 10, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 10, time = 10, timeUnit = TimeUnit.SECONDS) diff --git a/project/build.properties b/project/build.properties index 133a8f1..7c81737 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.17 +sbt.version=1.1.5 diff --git a/project/plugins.sbt b/project/plugins.sbt index 86528f7..dd1f200 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,7 +2,7 @@ logLevel := Level.Warn // sbt-jmh plugin - pulls in JMH dependencies too -addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.0") +addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.4") // sbt-dotty plugin - to support `scalaVersion := "0.x"` -addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.1.2") +addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.2.2")