Skip to content

Commit ef5b5fc

Browse files
authored
Merge pull request sbt#499 from retronym/disable-zinc-benchmark
Allow benchmark to disable zinc's APIExtract and Dependency phases
2 parents 23186cd + a53f032 commit ef5b5fc

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

internal/zinc-benchmarks/src/main/scala/xsbt/BenchmarkBase.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class BenchmarkBase {
1919
@Param(Array("")) var _tempDir: String = _
2020
var _project: BenchmarkProject = _
2121
var _subprojectToRun: String = _
22+
@Param(Array("true"))
23+
var zincEnabled: Boolean = _
2224

2325
/* Data filled in by the benchmark setup. */
2426
var _dir: File = _
@@ -39,7 +41,7 @@ class BenchmarkBase {
3941
_dir = new File(_tempDir)
4042
assert(_dir.exists(), s"Unexpected inexistent directory ${_tempDir}")
4143

42-
val compiler = new ZincBenchmark(_project)
44+
val compiler = new ZincBenchmark(_project, zincEnabled = this.zincEnabled)
4345
_subprojectsSetup = compiler.readSetup(_dir).getOrCrash
4446
assert(_subprojectsSetup.nonEmpty)
4547

internal/zinc-benchmarks/src/main/scala/xsbt/ZincBenchmark.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import sbt.internal.util.ConsoleLogger
1414
import sbt.io.{ IO, RichFile }
1515
import xsbt.ZincBenchmark.CompilationInfo
1616
import xsbti._
17-
import xsbti.compile.SingleOutput
17+
import xsbti.compile.{ IncOptions, SingleOutput }
1818

1919
import scala.util.Try
2020

@@ -49,7 +49,7 @@ case class ZincSetup(result: ZincBenchmark.Result[List[ProjectSetup]]) {
4949
/* Classes are defined `private[xsbt]` to avoid scoping issues w/ `CachedCompiler0`. */
5050

5151
/** Instantiate a `ZincBenchmark` from a given project. */
52-
private[xsbt] class ZincBenchmark(toCompile: BenchmarkProject) {
52+
private[xsbt] class ZincBenchmark(toCompile: BenchmarkProject, zincEnabled: Boolean = true) {
5353
import ZincBenchmark.WriteBuildInfo
5454

5555
def writeSetup(globalDir: File): WriteBuildInfo = {
@@ -74,7 +74,7 @@ private[xsbt] class ZincBenchmark(toCompile: BenchmarkProject) {
7474

7575
// Set up the compiler and store the current setup
7676
val javaFile = new RichFile(compilationDir) / "benchmark-target"
77-
val runGen = ZincBenchmark.setUpCompiler(buildInfo, javaFile)
77+
val runGen = ZincBenchmark.setUpCompiler(buildInfo, javaFile, zincEnabled)
7878
ProjectSetup(subproject, javaFile, buildInfo, runGen)
7979
}
8080

@@ -108,11 +108,14 @@ private[xsbt] object ZincBenchmark {
108108
/** Set up the compiler to compile `sources` with -cp `classpath` at `targetDir`. */
109109
def setUpCompiler(
110110
compilationInfo: CompilationInfo,
111-
targetDir: File
111+
targetDir: File,
112+
zincEnabled: Boolean
112113
): Generator = () => {
113114
IO.delete(targetDir)
114115
IO.createDirectory(targetDir)
115-
val callback = new xsbti.TestCallback
116+
val callback: xsbti.TestCallback = new xsbti.TestCallback {
117+
override def enabled: Boolean = zincEnabled
118+
}
116119
val compiler = prepareCompiler(targetDir, callback, compilationInfo)
117120
new compiler.Run
118121
}

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
addSbtPlugin("org.scala-sbt" % "sbt-houserules" % "0.3.5")
22
addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.2")
3-
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.27")
3+
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.3")
44
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "3.0.2")
55
addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.12-rc5")
66
libraryDependencies += "com.trueaccord.scalapb" %% "compilerplugin" % "0.6.0"

0 commit comments

Comments
 (0)