-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit splits project `bench` into multiple projects: `benchJavac18`, `benchRsc`, `benchScalac211` and `benchScalac212`. This provides additional flexibility and fine-grained control over target compiler versions. The main motivation for this change is the fact that neither Scala 2.11 nor Scala 2.12 clearly dominate one another on re2s. Scala 2.11 is faster in cold mode, whereas Scala 2.12 is faster in hot mode. While refactoring the benchmarking infrastructure to accommodate this change, I've also retired CliBench. It is confusing to have multiple benchmarks that test the same thing (ColdXxxYyy and CliXxxYyy), so I picked the one that's simpler, i.e. ColdXxxYyy powered by JMH. RscNativeTypecheck is still powered by CliBench-like logic, but it has been merged directly into that particular benchmark. I am not completely happy with the astonishing degree of duplication between benchScalac211 and benchScalac212, but my sbt skills don't allow me to remove this duplication in a satisfying manner. (I'm aware of ++, but I want Scala versions to be part of the project name, not an optional prefix to an sbt invocation.)
- Loading branch information
Showing
30 changed files
with
559 additions
and
256 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
// Copyright (c) 2017 Twitter, Inc. | ||
// Licensed under the Apache License, Version 2.0 (see LICENSE.md). | ||
package rsc.bench | ||
|
||
import java.io._ | ||
import java.nio.file.Files | ||
import scala.collection.JavaConverters._ | ||
|
||
trait FileFixtures { | ||
lazy val buildRoot: File = { | ||
BuildInfo.sourceRoot | ||
} | ||
|
||
lazy val re2jDir: File = { | ||
new File(s"$buildRoot/examples/re2j/src/main/java/java/util/regex") | ||
} | ||
|
||
lazy val re2jFiles: List[File] = { | ||
val stream = Files.newDirectoryStream(re2jDir.toPath) | ||
stream.asScala.map(_.toFile).toList | ||
} | ||
} |
This file contains 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 was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
bench/rsc/jvm/src/main/scala/rsc/bench/RscNativeTypecheck.scala
This file contains 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,42 @@ | ||
// Copyright (c) 2017 Twitter, Inc. | ||
// Licensed under the Apache License, Version 2.0 (see LICENSE.md). | ||
package rsc.bench | ||
|
||
import rsc.bench.RscNativeTypecheck._ | ||
|
||
object RscNativeTypecheck { | ||
class BenchmarkState extends FileFixtures | ||
} | ||
|
||
object CliRscNativeTypecheck { | ||
def main(args: Array[String]): Unit = { | ||
val Array(out) = args | ||
val bs = new BenchmarkState | ||
val fs = bs.re2sRscFiles.map(_.toString) | ||
val options = List("-Ystop-after:typecheck") ++ fs | ||
run(List(out) ++ options, runs = 100, iters = 1) | ||
run(List(out) ++ options, runs = 1, iters = 100) | ||
} | ||
|
||
private def run(command: List[String], runs: Int, iters: Int): Unit = { | ||
println(s"Running ${command.mkString(" ")} $runs x $iters times...") | ||
val times = 1.to(runs).map { i => | ||
val start = System.nanoTime() | ||
val process = new java.lang.ProcessBuilder() | ||
process.command((command ++ List("--iters", iters.toString)): _*) | ||
process.directory(rsc.bench.BuildInfo.sourceRoot) | ||
process.redirectOutput(ProcessBuilder.Redirect.INHERIT) | ||
process.redirectError(ProcessBuilder.Redirect.INHERIT) | ||
val exitcode = process.start().waitFor() | ||
if (exitcode != 0) { | ||
sys.error(s"Command has failed with code $exitcode") | ||
} | ||
val end = System.nanoTime() | ||
val result = 1.0 * (end - start) / 1000000 | ||
println(s"Run $i: $result ms") | ||
result | ||
} | ||
val result = times.sum / runs | ||
println(s"Average: " + result + " ms") | ||
} | ||
} |
This file contains 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 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 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 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 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 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 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
26 changes: 26 additions & 0 deletions
26
bench/rsc/shared/src/main/scala/rsc/bench/FileFixtures.scala
This file contains 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,26 @@ | ||
// Copyright (c) 2017 Twitter, Inc. | ||
// Licensed under the Apache License, Version 2.0 (see LICENSE.md). | ||
package rsc.bench | ||
|
||
import java.io._ | ||
import java.nio.file.Files | ||
import scala.collection.JavaConverters._ | ||
|
||
trait FileFixtures { | ||
lazy val buildRoot: File = { | ||
BuildInfo.sourceRoot | ||
} | ||
|
||
lazy val re2sDir: File = { | ||
new File(s"$buildRoot/examples/re2s/src/main/scala/java/util/regex") | ||
} | ||
|
||
lazy val re2sRscFiles: List[File] = { | ||
val stream = Files.newDirectoryStream(re2sDir.toPath) | ||
stream.asScala.map(_.toFile).toList :+ stdlibFile | ||
} | ||
|
||
lazy val stdlibFile: File = { | ||
new File(s"$buildRoot/stdlib/src/main/scala/Stdlib.scala") | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
bench/rsc/shared/src/main/scala/rsc/bench/RscFixtures.scala
This file contains 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,19 @@ | ||
// Copyright (c) 2017 Twitter, Inc. | ||
// Licensed under the Apache License, Version 2.0 (see LICENSE.md). | ||
package rsc.bench | ||
|
||
import rsc.Compiler | ||
import rsc.report._ | ||
import rsc.settings._ | ||
|
||
trait RscFixtures { | ||
def mkCompiler(args: Any*): Compiler = { | ||
val options = args.flatMap { | ||
case seq: Seq[_] => seq.map(_.toString) | ||
case other => List(other.toString) | ||
} | ||
val settings = Settings.parse(options.toList).get | ||
val reporter = StoreReporter(settings) | ||
Compiler(settings, reporter) | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
bench/scalac211/src/main/scala/rsc/bench/FileFixtures.scala
This file contains 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 @@ | ||
// Copyright (c) 2017 Twitter, Inc. | ||
// Licensed under the Apache License, Version 2.0 (see LICENSE.md). | ||
package rsc.bench | ||
|
||
import java.io._ | ||
import java.nio.file.Files | ||
import scala.collection.JavaConverters._ | ||
|
||
trait FileFixtures { | ||
lazy val buildRoot: File = { | ||
BuildInfo.sourceRoot | ||
} | ||
|
||
lazy val re2sDir: File = { | ||
new File(s"$buildRoot/examples/re2s/src/main/scala/java/util/regex") | ||
} | ||
|
||
lazy val re2sScalacFiles: List[File] = { | ||
val stream = Files.newDirectoryStream(re2sDir.toPath) | ||
stream.asScala.map(_.toFile).toList | ||
} | ||
} |
This file contains 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
Oops, something went wrong.