-
Notifications
You must be signed in to change notification settings - Fork 31
Compile benchmark with Dotty, fixes #29. #31
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
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
700448d
Compile benchmark with Dotty, fixes #29.
olafurpg 16fe81a
Re-enable FileVisitOption.FOLLOW_LINKS.
olafurpg 1bd6dd5
Uncomment `@Fork`.
olafurpg ccc6b38
Set corpusVersion in compilation/test.
olafurpg 49b2fb0
Explain `fork in (Test, test) := true`.
olafurpg ef391dd
Fix rebase on master.
olafurpg 1a975a9
Fix -migration warning.
olafurpg 88190e1
Test dotty compilation in CI.
olafurpg 6ed08f2
Change order of tests on CI.
olafurpg ab1080a
Run dotty jmh benchmarks in CI.
olafurpg 4f27da1
Reuse extraArgs logic for dotc and scalac.
olafurpg 0a937bb
Remove outdated comment, the annotation issue has been fixed
olafurpg dd00264
Reuse scala211 and dottyLatest variables in testAll.
olafurpg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,21 @@ name := "compiler-benchmark" | |
|
||
version := "1.0-SNAPSHOT" | ||
|
||
scalaVersion in ThisBuild := "2.11.8" | ||
def scala211 = "2.11.11" | ||
def dottyLatest = "0.2.0-RC1" | ||
scalaVersion in ThisBuild := scala211 | ||
|
||
commands += Command.command("testAll") { s => | ||
"test:compile" :: | ||
"compilation/test" :: | ||
"hot -psource=scalap -wi 1 -i 1 -f1" :: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note. I bumped down the warmup iterations from 10 to 1 to make the tests run faster. The benchmark numbers on Travis are too unreliable anyways. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
s"++$dottyLatest" :: | ||
"compilation/test" :: | ||
"hot -psource=vector -wi 1 -i 1 -f1" :: | ||
s"++$scala211" :: | ||
"micro/jmh:run -w1 -f1" :: | ||
s | ||
} | ||
|
||
resolvers += "scala-integration" at "https://scala-ci.typesafe.com/artifactory/scala-integration/" | ||
|
||
|
@@ -36,8 +50,17 @@ lazy val compilation = addJmh(project).settings( | |
// We should be able to switch this project to a broad range of Scala versions for comparative | ||
// benchmarking. As such, this project should only depend on the high level `MainClass` compiler API. | ||
description := "Black box benchmark of the compiler", | ||
libraryDependencies += scalaOrganization.value % "scala-compiler" % scalaVersion.value, | ||
mainClass in (Jmh, run) := Some("scala.bench.ScalacBenchmarkRunner") | ||
libraryDependencies += { | ||
if (isDotty.value) "ch.epfl.lamp" %% "dotty-compiler" % scalaVersion.value | ||
else scalaOrganization.value % "scala-compiler" % scalaVersion.value | ||
}, | ||
crossScalaVersions := List(scala211, dottyLatest), | ||
unmanagedSourceDirectories.in(Compile) += | ||
sourceDirectory.in(Compile).value / (if (isDotty.value) "dotc" else "scalac"), | ||
mainClass in (Jmh, run) := Some("scala.bench.ScalacBenchmarkRunner"), | ||
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test, | ||
testOptions in Test += Tests.Argument(TestFrameworks.JUnit), | ||
fork in (Test, test) := true // jmh scoped tasks run with fork := true. | ||
).settings(addJavaOptions).dependsOn(infrastructure) | ||
|
||
lazy val micro = addJmh(project).settings( | ||
|
22 changes: 22 additions & 0 deletions
22
compilation/src/main/dotc/scala/tools/benchmark/BenchmarkDriver.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package scala.tools.benchmark | ||
|
||
import java.io.File | ||
import scala.tools.nsc.BaseBenchmarkDriver | ||
import dotty.tools.dotc.core.Contexts.ContextBase | ||
|
||
trait BenchmarkDriver extends BaseBenchmarkDriver { | ||
def compileImpl(): Unit = { | ||
implicit val ctx = new ContextBase().initialCtx.fresh | ||
ctx.setSetting(ctx.settings.usejavacp, true) | ||
if (depsClasspath != null) { | ||
ctx.setSetting(ctx.settings.classpath, | ||
depsClasspath.mkString(File.pathSeparator)) | ||
} | ||
ctx.setSetting(ctx.settings.migration, true) | ||
ctx.setSetting(ctx.settings.d, 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) | ||
assert(!reporter.hasErrors) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
compilation/src/main/scalac/scala/tools/benchmark/BenchmarkDriver.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package scala.tools.benchmark | ||
|
||
import java.nio.file._ | ||
import scala.tools.nsc._ | ||
|
||
trait BenchmarkDriver extends BaseBenchmarkDriver { | ||
def compileImpl(): Unit = { | ||
// MainClass is copy-pasted from compiler for source compatibility with 2.10.x - 2.13.x | ||
class MainClass extends Driver with EvalLoop { | ||
def resident(compiler: Global): Unit = loop { line => | ||
val command = new CompilerCommand(line split "\\s+" toList, new Settings(scalacError)) | ||
compiler.reporter.reset() | ||
new compiler.Run() compile command.files | ||
} | ||
|
||
override def newCompiler(): Global = Global(settings, reporter) | ||
|
||
override protected def processSettingsHook(): Boolean = { | ||
if (source == "scala") | ||
settings.sourcepath.value = Paths.get(s"../corpus/$source/$corpusVersion/library").toAbsolutePath.normalize.toString | ||
else | ||
settings.usejavacp.value = true | ||
settings.outdir.value = tempDir.getAbsolutePath | ||
settings.nowarn.value = true | ||
if (depsClasspath != null) | ||
settings.processArgumentString(s"-cp $depsClasspath") | ||
true | ||
} | ||
} | ||
val driver = new MainClass | ||
driver.process(allArgs.toArray) | ||
assert(!driver.reporter.hasErrors) | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
compilation/src/test/scala/scala/tools/benchmark/BenchmarkTest.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package scala.tools.benchmark | ||
|
||
import scala.tools.nsc.ScalacBenchmark | ||
import org.junit.Test | ||
|
||
class BenchmarkTest { | ||
@Test def compilesOK() = { | ||
val bench = new ScalacBenchmark | ||
bench.source = "../corpus/vector" | ||
bench.corpusVersion = "latest" | ||
bench.initTemp() | ||
bench.compileImpl() | ||
bench.clearTemp() | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be done on dotty too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is done in Dotty as well, see L14.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+compilation/test
would not run on Dotty because it uses crossScalaVersions from the root project. Alternatives areproject compilation; +test ; project compiler-benchmark
such compilation/test
I opted for duplication since it's the dumbest solution.