Skip to content

Make SBT based benchmarking more flexible #33

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 1 commit into from
Jun 20, 2017
Merged
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
27 changes: 26 additions & 1 deletion compilation/src/main/scala/scala/tools/nsc/HotSbtBenchmark.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class HotSbtBenchmark {
@Param(value = Array("0.13.15"))
var sbtVersion: String = _

@Param(value = Array(""))
var extraBuild: String = _

@Param(value= Array("compile"))
var compileCmd: String = _

// This parameter is set by ScalacBenchmarkRunner / UploadingRunner based on the Scala version.
// When running the benchmark directly the "latest" symlink is used.
@Param(value = Array("latest"))
Expand All @@ -42,6 +48,19 @@ class HotSbtBenchmark {
var processInputReader: BufferedWriter = _
var output= new java.lang.StringBuilder()

def compileRawSetting = if (sbtVersion.startsWith("1.")) "" else
"""
|val compileRaw = taskKey[Unit]("Compile directly, bypassing the incremental compiler")
|
|def addCompileRaw = compileRaw := {
| val compiler = new sbt.compiler.RawCompiler(scalaInstance.value, sbt.ClasspathOptions.auto, streams.value.log)
| classDirectory.value.mkdirs()
| compiler.apply(sources.value, classDirectory.value +: dependencyClasspath.value.map(_.data), classDirectory.value, scalacOptions.value)
| }
|
|inConfig(Compile)(List(addCompileRaw))
""".stripMargin

def buildDef =
s"""
|scalaHome := Some(file("${scalaHome.toAbsolutePath.toString}"))
Expand All @@ -55,6 +74,12 @@ class HotSbtBenchmark {
|libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value
|libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value
|
|traceLevel := Int.MaxValue
|traceLevel in runMain := Int.MaxValue
|
|$compileRawSetting
|
|$extraBuild
|// TODO support .java sources
""".stripMargin

Expand All @@ -79,7 +104,7 @@ class HotSbtBenchmark {

@Benchmark
def compile(): Unit = {
issue(";cleanClasses;compile")
issue(s";cleanClasses;$compileCmd")
awaitPrompt()
}

Expand Down