Skip to content

Commit d0f038e

Browse files
authored
Merge pull request #33 from retronym/topic/sbt-bench-tweak
Make SBT based benchmarking more flexible
2 parents d7eec06 + 4ccfda1 commit d0f038e

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

compilation/src/main/scala/scala/tools/nsc/HotSbtBenchmark.scala

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ class HotSbtBenchmark {
2828
@Param(value = Array("0.13.15"))
2929
var sbtVersion: String = _
3030

31+
@Param(value = Array(""))
32+
var extraBuild: String = _
33+
34+
@Param(value= Array("compile"))
35+
var compileCmd: String = _
36+
3137
// This parameter is set by ScalacBenchmarkRunner / UploadingRunner based on the Scala version.
3238
// When running the benchmark directly the "latest" symlink is used.
3339
@Param(value = Array("latest"))
@@ -42,6 +48,19 @@ class HotSbtBenchmark {
4248
var processInputReader: BufferedWriter = _
4349
var output= new java.lang.StringBuilder()
4450

51+
def compileRawSetting = if (sbtVersion.startsWith("1.")) "" else
52+
"""
53+
|val compileRaw = taskKey[Unit]("Compile directly, bypassing the incremental compiler")
54+
|
55+
|def addCompileRaw = compileRaw := {
56+
| val compiler = new sbt.compiler.RawCompiler(scalaInstance.value, sbt.ClasspathOptions.auto, streams.value.log)
57+
| classDirectory.value.mkdirs()
58+
| compiler.apply(sources.value, classDirectory.value +: dependencyClasspath.value.map(_.data), classDirectory.value, scalacOptions.value)
59+
| }
60+
|
61+
|inConfig(Compile)(List(addCompileRaw))
62+
""".stripMargin
63+
4564
def buildDef =
4665
s"""
4766
|scalaHome := Some(file("${scalaHome.toAbsolutePath.toString}"))
@@ -55,6 +74,12 @@ class HotSbtBenchmark {
5574
|libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value
5675
|libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value
5776
|
77+
|traceLevel := Int.MaxValue
78+
|traceLevel in runMain := Int.MaxValue
79+
|
80+
|$compileRawSetting
81+
|
82+
|$extraBuild
5883
|// TODO support .java sources
5984
""".stripMargin
6085

@@ -79,7 +104,7 @@ class HotSbtBenchmark {
79104

80105
@Benchmark
81106
def compile(): Unit = {
82-
issue(";cleanClasses;compile")
107+
issue(s";cleanClasses;$compileCmd")
83108
awaitPrompt()
84109
}
85110

0 commit comments

Comments
 (0)