diff --git a/bench/javac18/src/main/scala/rsc/bench/FileFixtures.scala b/bench/javac18/src/main/scala/rsc/bench/FileFixtures.scala new file mode 100644 index 00000000..ad9e4cd9 --- /dev/null +++ b/bench/javac18/src/main/scala/rsc/bench/FileFixtures.scala @@ -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 + } +} diff --git a/bench/jvm/src/main/scala/rsc/bench/JavacCompile.scala b/bench/javac18/src/main/scala/rsc/bench/JavacCompile.scala similarity index 85% rename from bench/jvm/src/main/scala/rsc/bench/JavacCompile.scala rename to bench/javac18/src/main/scala/rsc/bench/JavacCompile.scala index 50face1b..2c5bacf5 100644 --- a/bench/jvm/src/main/scala/rsc/bench/JavacCompile.scala +++ b/bench/javac18/src/main/scala/rsc/bench/JavacCompile.scala @@ -8,11 +8,10 @@ import javax.tools._ import org.openjdk.jmh.annotations._ import org.openjdk.jmh.annotations.Mode._ import rsc.bench.JavacCompile._ -import rsc.tests._ object JavacCompile { @State(Scope.Benchmark) - class BenchmarkState extends RscFixtures { + class BenchmarkState extends FileFixtures { val compiler = ToolProvider.getSystemJavaCompiler() val re2jFilenames = re2jFiles.map(_.getAbsolutePath) val outDir = Files.createTempDirectory("javac_") @@ -20,15 +19,6 @@ object JavacCompile { } } -object CliJavacCompile { - def main(args: Array[String]): Unit = { - val Array(expectedJavacVersion) = args - val bs = new JavacCompile.BenchmarkState - val command = List("javac") ++ bs.options - CliBench.run(command, runs = 100) - } -} - trait JavacCompile { def runImpl(bs: BenchmarkState): Unit = { val exitCode = bs.compiler.run(null, null, null, bs.options: _*) diff --git a/bench/jvm/src/main/scala/rsc/bench/CliBench.scala b/bench/jvm/src/main/scala/rsc/bench/CliBench.scala deleted file mode 100644 index c392142f..00000000 --- a/bench/jvm/src/main/scala/rsc/bench/CliBench.scala +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2017 Twitter, Inc. -// Licensed under the Apache License, Version 2.0 (see LICENSE.md). -package rsc.bench - -object CliBench { - private def time(command: List[String]): Double = { - val start = System.nanoTime() - val process = new java.lang.ProcessBuilder() - process.command(command: _*) - 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() - 1.0 * (end - start) / 1000000 - } - - def run(command: List[String], runs: Int): Unit = { - println(s"Running ${command.mkString(" ")} $runs times...") - val times = 1.to(runs).map { i => - val result = time(command) - println(s"Run $i: $result ms") - result - } - val result = times.sum / runs - println(s"Average: " + result + " ms") - } -} diff --git a/bench/rsc/jvm/src/main/scala/rsc/bench/RscNativeTypecheck.scala b/bench/rsc/jvm/src/main/scala/rsc/bench/RscNativeTypecheck.scala new file mode 100644 index 00000000..a8ef8a0e --- /dev/null +++ b/bench/rsc/jvm/src/main/scala/rsc/bench/RscNativeTypecheck.scala @@ -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") + } +} diff --git a/bench/jvm/src/main/scala/rsc/bench/RscOutline.scala b/bench/rsc/jvm/src/main/scala/rsc/bench/RscOutline.scala similarity index 95% rename from bench/jvm/src/main/scala/rsc/bench/RscOutline.scala rename to bench/rsc/jvm/src/main/scala/rsc/bench/RscOutline.scala index cd701fcc..0338191b 100644 --- a/bench/jvm/src/main/scala/rsc/bench/RscOutline.scala +++ b/bench/rsc/jvm/src/main/scala/rsc/bench/RscOutline.scala @@ -7,16 +7,15 @@ import org.openjdk.jmh.annotations._ import org.openjdk.jmh.annotations.Mode._ import rsc.bench.RscOutline._ import rsc.semantics._ -import rsc.tests._ object RscOutline { @State(Scope.Benchmark) - class BenchmarkState extends RscFixtures + class BenchmarkState extends RscFixtures with FileFixtures } trait RscOutline { def runImpl(bs: BenchmarkState): Unit = { - val compiler = bs.mkCompiler("-Ystop-after:outline", bs.re2sFiles) + val compiler = bs.mkCompiler("-Ystop-after:outline", bs.re2sRscFiles) compiler.run() val problems = compiler.reporter.problems if (problems.nonEmpty) { diff --git a/bench/jvm/src/main/scala/rsc/bench/RscParse.scala b/bench/rsc/jvm/src/main/scala/rsc/bench/RscParse.scala similarity index 93% rename from bench/jvm/src/main/scala/rsc/bench/RscParse.scala rename to bench/rsc/jvm/src/main/scala/rsc/bench/RscParse.scala index b38a3ff6..9dbae619 100644 --- a/bench/jvm/src/main/scala/rsc/bench/RscParse.scala +++ b/bench/rsc/jvm/src/main/scala/rsc/bench/RscParse.scala @@ -10,12 +10,11 @@ import rsc.lexis._ import rsc.parse._ import rsc.report._ import rsc.settings._ -import rsc.tests._ object RscParse { @State(Scope.Benchmark) - class BenchmarkState extends RscFixtures { - val settings = Settings.parse(re2sFiles.map(_.toString)).get + class BenchmarkState extends FileFixtures { + val settings = Settings.parse(re2sRscFiles.map(_.toString)).get val reporter = StoreReporter(settings) val inputs = settings.ins.map(Input.apply).toArray } diff --git a/bench/jvm/src/main/scala/rsc/bench/RscScan.scala b/bench/rsc/jvm/src/main/scala/rsc/bench/RscScan.scala similarity index 93% rename from bench/jvm/src/main/scala/rsc/bench/RscScan.scala rename to bench/rsc/jvm/src/main/scala/rsc/bench/RscScan.scala index 665d2d75..64cda7f6 100644 --- a/bench/jvm/src/main/scala/rsc/bench/RscScan.scala +++ b/bench/rsc/jvm/src/main/scala/rsc/bench/RscScan.scala @@ -10,12 +10,11 @@ import rsc.lexis._ import rsc.report._ import rsc.scan._ import rsc.settings._ -import rsc.tests._ object RscScan { @State(Scope.Benchmark) - class BenchmarkState extends RscFixtures { - val settings = Settings.parse(re2sFiles.map(_.toString)).get + class BenchmarkState extends FileFixtures { + val settings = Settings.parse(re2sRscFiles.map(_.toString)).get val reporter = StoreReporter(settings) val inputs = settings.ins.map(Input.apply).toArray } diff --git a/bench/jvm/src/main/scala/rsc/bench/RscSchedule.scala b/bench/rsc/jvm/src/main/scala/rsc/bench/RscSchedule.scala similarity index 95% rename from bench/jvm/src/main/scala/rsc/bench/RscSchedule.scala rename to bench/rsc/jvm/src/main/scala/rsc/bench/RscSchedule.scala index 31cc2ff7..e4bb57a4 100644 --- a/bench/jvm/src/main/scala/rsc/bench/RscSchedule.scala +++ b/bench/rsc/jvm/src/main/scala/rsc/bench/RscSchedule.scala @@ -7,16 +7,15 @@ import org.openjdk.jmh.annotations._ import org.openjdk.jmh.annotations.Mode._ import rsc.bench.RscSchedule._ import rsc.semantics._ -import rsc.tests._ object RscSchedule { @State(Scope.Benchmark) - class BenchmarkState extends RscFixtures + class BenchmarkState extends RscFixtures with FileFixtures } trait RscSchedule { def runImpl(bs: BenchmarkState): Unit = { - val compiler = bs.mkCompiler("-Ystop-after:schedule", bs.re2sFiles) + val compiler = bs.mkCompiler("-Ystop-after:schedule", bs.re2sRscFiles) compiler.run() val problems = compiler.reporter.problems if (problems.nonEmpty) { diff --git a/bench/jvm/src/main/scala/rsc/bench/RscScope.scala b/bench/rsc/jvm/src/main/scala/rsc/bench/RscScope.scala similarity index 92% rename from bench/jvm/src/main/scala/rsc/bench/RscScope.scala rename to bench/rsc/jvm/src/main/scala/rsc/bench/RscScope.scala index e62f9989..d29ab35f 100644 --- a/bench/jvm/src/main/scala/rsc/bench/RscScope.scala +++ b/bench/rsc/jvm/src/main/scala/rsc/bench/RscScope.scala @@ -7,16 +7,15 @@ import org.openjdk.jmh.annotations._ import org.openjdk.jmh.annotations.Mode._ import rsc.bench.RscScope._ import rsc.semantics._ -import rsc.tests._ object RscScope { @State(Scope.Benchmark) - class BenchmarkState extends RscFixtures + class BenchmarkState extends RscFixtures with FileFixtures } trait RscScope { def runImpl(bs: BenchmarkState): Unit = { - val compiler = bs.mkCompiler("-Ystop-after:scope", bs.re2sFiles) + val compiler = bs.mkCompiler("-Ystop-after:scope", bs.re2sRscFiles) compiler.run() val problems = compiler.reporter.problems if (problems.nonEmpty) { diff --git a/bench/jvm/src/main/scala/rsc/bench/RscTypecheck.scala b/bench/rsc/jvm/src/main/scala/rsc/bench/RscTypecheck.scala similarity index 65% rename from bench/jvm/src/main/scala/rsc/bench/RscTypecheck.scala rename to bench/rsc/jvm/src/main/scala/rsc/bench/RscTypecheck.scala index 3861e068..def3a8a6 100644 --- a/bench/jvm/src/main/scala/rsc/bench/RscTypecheck.scala +++ b/bench/rsc/jvm/src/main/scala/rsc/bench/RscTypecheck.scala @@ -7,40 +7,15 @@ import org.openjdk.jmh.annotations._ import org.openjdk.jmh.annotations.Mode._ import rsc.bench.RscTypecheck._ import rsc.semantics._ -import rsc.tests._ object RscTypecheck { @State(Scope.Benchmark) - class BenchmarkState extends RscFixtures -} - -object CliRscTypecheck { - def main(args: Array[String]): Unit = { - val Array(classpath) = args - val bs = new ScalacCompile.BenchmarkState - val fs = bs.re2sFiles.map(_.toString) - val options = List("-Ystop-after:typecheck") ++ fs - val command = List("scala", "-cp", classpath, "rsc.bench.Main") ++ options - CliBench.run(command, runs = 100) - } -} - -object CliRscNativeTypecheck { - def main(args: Array[String]): Unit = { - val Array(out) = args - val bs = new ScalacCompile.BenchmarkState - val fs = bs.re2sFiles.map(_.toString) - val options = List("-Ystop-after:typecheck") ++ fs - val command1 = List(out) ++ options ++ List("--runs", "1") - CliBench.run(command1, runs = 100) - val command2 = List(out) ++ options ++ List("--runs", "100") - CliBench.run(command2, runs = 1) - } + class BenchmarkState extends RscFixtures with FileFixtures } trait RscTypecheck { def runImpl(bs: BenchmarkState): Unit = { - val compiler = bs.mkCompiler("-Ystop-after:typecheck", bs.re2sFiles) + val compiler = bs.mkCompiler("-Ystop-after:typecheck", bs.re2sRscFiles) compiler.run() val problems = compiler.reporter.problems if (problems.nonEmpty) { diff --git a/bench/shared/src/main/scala/rsc/bench/Main.scala b/bench/rsc/native/src/main/scala/rsc/bench/Main.scala similarity index 77% rename from bench/shared/src/main/scala/rsc/bench/Main.scala rename to bench/rsc/native/src/main/scala/rsc/bench/Main.scala index d1509b8d..7afe6f90 100644 --- a/bench/shared/src/main/scala/rsc/bench/Main.scala +++ b/bench/rsc/native/src/main/scala/rsc/bench/Main.scala @@ -13,7 +13,7 @@ object Main { } def run(args: Array[String]): Int = { - case class BenchSettings(args1: List[String] = Nil, runs: Int = 1) + case class BenchSettings(args1: List[String] = Nil, iters: Int = 1) def loop( settings: BenchSettings, allowOptions: Boolean, @@ -21,17 +21,17 @@ object Main { args match { case "--" +: rest => loop(settings, false, args) - case "--runs" +: s_runs +: rest if allowOptions => - loop(settings.copy(runs = s_runs.toInt), true, rest) + case "--iters" +: s_iters +: rest if allowOptions => + loop(settings.copy(iters = s_iters.toInt), true, rest) case arg +: rest => loop(settings.copy(args1 = settings.args1 :+ arg), allowOptions, rest) case Nil => settings } } - val BenchSettings(args1, runs) = loop(BenchSettings(), true, args.toList) + val BenchSettings(args1, iters) = loop(BenchSettings(), true, args.toList) - for (i <- 1 to runs) { + for (i <- 1 to iters) { Settings.parse(args1) match { case Some(settings) => val reporter = ConsoleReporter(settings) diff --git a/bench/rsc/shared/src/main/scala/rsc/bench/FileFixtures.scala b/bench/rsc/shared/src/main/scala/rsc/bench/FileFixtures.scala new file mode 100644 index 00000000..2c59855b --- /dev/null +++ b/bench/rsc/shared/src/main/scala/rsc/bench/FileFixtures.scala @@ -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") + } +} diff --git a/bench/rsc/shared/src/main/scala/rsc/bench/RscFixtures.scala b/bench/rsc/shared/src/main/scala/rsc/bench/RscFixtures.scala new file mode 100644 index 00000000..159e21c4 --- /dev/null +++ b/bench/rsc/shared/src/main/scala/rsc/bench/RscFixtures.scala @@ -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) + } +} diff --git a/bench/scalac211/src/main/scala/rsc/bench/FileFixtures.scala b/bench/scalac211/src/main/scala/rsc/bench/FileFixtures.scala new file mode 100644 index 00000000..c9da0652 --- /dev/null +++ b/bench/scalac211/src/main/scala/rsc/bench/FileFixtures.scala @@ -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 + } +} diff --git a/bench/jvm/src/main/scala/rsc/bench/ScalacCompile.scala b/bench/scalac211/src/main/scala/rsc/bench/ScalacCompile.scala similarity index 79% rename from bench/jvm/src/main/scala/rsc/bench/ScalacCompile.scala rename to bench/scalac211/src/main/scala/rsc/bench/ScalacCompile.scala index ac837de0..edab70bc 100644 --- a/bench/jvm/src/main/scala/rsc/bench/ScalacCompile.scala +++ b/bench/scalac211/src/main/scala/rsc/bench/ScalacCompile.scala @@ -9,22 +9,10 @@ import org.openjdk.jmh.annotations.Mode._ import scala.tools.nsc._ import scala.tools.nsc.reporters._ import rsc.bench.ScalacCompile._ -import rsc.tests._ object ScalacCompile { @State(Scope.Benchmark) - class BenchmarkState extends RscFixtures -} - -object CliScalacCompile { - def main(args: Array[String]): Unit = { - val Array(expectedScalacVersion) = args - val bs = new ScalacCompile.BenchmarkState - val outdir = Files.createTempDirectory("scalac_").toString - val fs = bs.re2sFiles.init.map(_.toString) - val command = List("scalac", "-d", outdir, "-usejavacp") ++ fs - CliBench.run(command, runs = 100) - } + class BenchmarkState extends FileFixtures } trait ScalacCompile { @@ -35,7 +23,7 @@ trait ScalacCompile { val reporter = new StoreReporter val global = Global(settings, reporter) val run = new global.Run - run.compile(bs.re2sFiles.init.map(_.toString)) + run.compile(bs.re2sScalacFiles.map(_.toString)) if (reporter.hasErrors) { reporter.infos.foreach(println) sys.error("compile failed") diff --git a/bench/jvm/src/main/scala/rsc/bench/ScalacParse.scala b/bench/scalac211/src/main/scala/rsc/bench/ScalacParse.scala similarity index 94% rename from bench/jvm/src/main/scala/rsc/bench/ScalacParse.scala rename to bench/scalac211/src/main/scala/rsc/bench/ScalacParse.scala index 9599619f..0bef02dd 100644 --- a/bench/jvm/src/main/scala/rsc/bench/ScalacParse.scala +++ b/bench/scalac211/src/main/scala/rsc/bench/ScalacParse.scala @@ -11,18 +11,17 @@ import scala.reflect.internal.util._ import scala.tools.nsc._ import scala.tools.nsc.reporters._ import rsc.bench.ScalacParse._ -import rsc.tests._ object ScalacParse { @State(Scope.Benchmark) - class BenchmarkState extends RscFixtures { + class BenchmarkState extends FileFixtures { val settings = new Settings settings.outdir.value = Files.createTempDirectory("scalac_").toString settings.usejavacp.value = true val reporter = new StoreReporter val global = Global(settings, reporter) val run = new global.Run - val abstractFiles = re2sFiles.init.map(f => AbstractFile.getFile(f)) + val abstractFiles = re2sScalacFiles.map(f => AbstractFile.getFile(f)) val sourceFiles = abstractFiles.map(f => new BatchSourceFile(f)).toArray } } diff --git a/bench/jvm/src/main/scala/rsc/bench/ScalacScan.scala b/bench/scalac211/src/main/scala/rsc/bench/ScalacScan.scala similarity index 94% rename from bench/jvm/src/main/scala/rsc/bench/ScalacScan.scala rename to bench/scalac211/src/main/scala/rsc/bench/ScalacScan.scala index fba0e45c..f10bd40c 100644 --- a/bench/jvm/src/main/scala/rsc/bench/ScalacScan.scala +++ b/bench/scalac211/src/main/scala/rsc/bench/ScalacScan.scala @@ -12,18 +12,17 @@ import scala.tools.nsc._ import scala.tools.nsc.ast.parser.Tokens._ import scala.tools.nsc.reporters._ import rsc.bench.ScalacScan._ -import rsc.tests._ object ScalacScan { @State(Scope.Benchmark) - class BenchmarkState extends RscFixtures { + class BenchmarkState extends FileFixtures { val settings = new Settings settings.outdir.value = Files.createTempDirectory("scalac_").toString settings.usejavacp.value = true val reporter = new StoreReporter val global = Global(settings, reporter) val run = new global.Run - val abstractFiles = re2sFiles.init.map(f => AbstractFile.getFile(f)) + val abstractFiles = re2sScalacFiles.map(f => AbstractFile.getFile(f)) val sourceFiles = abstractFiles.map(f => new BatchSourceFile(f)).toArray } } diff --git a/bench/jvm/src/main/scala/rsc/bench/ScalacTypecheck.scala b/bench/scalac211/src/main/scala/rsc/bench/ScalacTypecheck.scala similarity index 77% rename from bench/jvm/src/main/scala/rsc/bench/ScalacTypecheck.scala rename to bench/scalac211/src/main/scala/rsc/bench/ScalacTypecheck.scala index 85901720..eeb64a98 100644 --- a/bench/jvm/src/main/scala/rsc/bench/ScalacTypecheck.scala +++ b/bench/scalac211/src/main/scala/rsc/bench/ScalacTypecheck.scala @@ -9,23 +9,10 @@ import org.openjdk.jmh.annotations.Mode._ import scala.tools.nsc._ import scala.tools.nsc.reporters._ import rsc.bench.ScalacTypecheck._ -import rsc.tests._ object ScalacTypecheck { @State(Scope.Benchmark) - class BenchmarkState extends RscFixtures -} - -object CliScalacTypecheck { - def main(args: Array[String]): Unit = { - val Array(expectedScalacVersion) = args - val bs = new ScalacCompile.BenchmarkState - val outdir = Files.createTempDirectory("scalac_").toString - val fs = bs.re2sFiles.init.map(_.toString) - val stop = List("-Ystop-after:typer") - val command = List("scalac", "-d", outdir, "-usejavacp") ++ stop ++ fs - CliBench.run(command, runs = 100) - } + class BenchmarkState extends FileFixtures } trait ScalacTypecheck { @@ -37,7 +24,7 @@ trait ScalacTypecheck { val reporter = new StoreReporter val global = Global(settings, reporter) val run = new global.Run - run.compile(bs.re2sFiles.init.map(_.toString)) + run.compile(bs.re2sScalacFiles.map(_.toString)) if (reporter.hasErrors) { reporter.infos.foreach(println) sys.error("typecheck failed") diff --git a/bench/scalac212/src/main/scala/rsc/bench/FileFixtures.scala b/bench/scalac212/src/main/scala/rsc/bench/FileFixtures.scala new file mode 100644 index 00000000..c9da0652 --- /dev/null +++ b/bench/scalac212/src/main/scala/rsc/bench/FileFixtures.scala @@ -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 + } +} diff --git a/bench/scalac212/src/main/scala/rsc/bench/ScalacCompile.scala b/bench/scalac212/src/main/scala/rsc/bench/ScalacCompile.scala new file mode 100644 index 00000000..edab70bc --- /dev/null +++ b/bench/scalac212/src/main/scala/rsc/bench/ScalacCompile.scala @@ -0,0 +1,66 @@ +// Copyright (c) 2017 Twitter, Inc. +// Licensed under the Apache License, Version 2.0 (see LICENSE.md). +package rsc.bench + +import java.nio.file._ +import java.util.concurrent.TimeUnit +import org.openjdk.jmh.annotations._ +import org.openjdk.jmh.annotations.Mode._ +import scala.tools.nsc._ +import scala.tools.nsc.reporters._ +import rsc.bench.ScalacCompile._ + +object ScalacCompile { + @State(Scope.Benchmark) + class BenchmarkState extends FileFixtures +} + +trait ScalacCompile { + def runImpl(bs: BenchmarkState): Unit = { + val settings = new Settings + settings.outdir.value = Files.createTempDirectory("scalac_").toString + settings.usejavacp.value = true + val reporter = new StoreReporter + val global = Global(settings, reporter) + val run = new global.Run + run.compile(bs.re2sScalacFiles.map(_.toString)) + if (reporter.hasErrors) { + reporter.infos.foreach(println) + sys.error("compile failed") + } + } +} + +@BenchmarkMode(Array(SingleShotTime)) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Fork(value = 128, jvmArgs = Array("-Xms2G", "-Xmx2G")) +class ColdScalacCompile extends ScalacCompile { + @Benchmark + def run(bs: BenchmarkState): Unit = { + runImpl(bs) + } +} + +@BenchmarkMode(Array(SampleTime)) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(value = 1, jvmArgs = Array("-Xms2G", "-Xmx2G")) +class WarmScalacCompile extends ScalacCompile { + @Benchmark + def run(bs: BenchmarkState): Unit = { + runImpl(bs) + } +} + +@BenchmarkMode(Array(SampleTime)) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Warmup(iterations = 10, time = 10, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 10, time = 10, timeUnit = TimeUnit.SECONDS) +@Fork(value = 3, jvmArgs = Array("-Xms2G", "-Xmx2G")) +class HotScalacCompile extends ScalacCompile { + @Benchmark + def run(bs: BenchmarkState): Unit = { + runImpl(bs) + } +} diff --git a/bench/scalac212/src/main/scala/rsc/bench/ScalacParse.scala b/bench/scalac212/src/main/scala/rsc/bench/ScalacParse.scala new file mode 100644 index 00000000..0bef02dd --- /dev/null +++ b/bench/scalac212/src/main/scala/rsc/bench/ScalacParse.scala @@ -0,0 +1,77 @@ +// Copyright (c) 2017 Twitter, Inc. +// Licensed under the Apache License, Version 2.0 (see LICENSE.md). +package rsc.bench + +import java.nio.file._ +import java.util.concurrent.TimeUnit +import org.openjdk.jmh.annotations._ +import org.openjdk.jmh.annotations.Mode._ +import scala.reflect.io._ +import scala.reflect.internal.util._ +import scala.tools.nsc._ +import scala.tools.nsc.reporters._ +import rsc.bench.ScalacParse._ + +object ScalacParse { + @State(Scope.Benchmark) + class BenchmarkState extends FileFixtures { + val settings = new Settings + settings.outdir.value = Files.createTempDirectory("scalac_").toString + settings.usejavacp.value = true + val reporter = new StoreReporter + val global = Global(settings, reporter) + val run = new global.Run + val abstractFiles = re2sScalacFiles.map(f => AbstractFile.getFile(f)) + val sourceFiles = abstractFiles.map(f => new BatchSourceFile(f)).toArray + } +} + +trait ScalacParse { + def runImpl(bs: BenchmarkState): Unit = { + var i = 0 + while (i < bs.sourceFiles.length) { + val sourceFile = bs.sourceFiles(i) + val parser = new bs.global.syntaxAnalyzer.SourceFileParser(sourceFile) + parser.parse() + i += 1 + } + if (bs.reporter.hasErrors) { + bs.reporter.infos.foreach(println) + sys.error("parse failed") + } + } +} + +@BenchmarkMode(Array(SingleShotTime)) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Fork(value = 128, jvmArgs = Array("-Xms2G", "-Xmx2G")) +class ColdScalacParse extends ScalacParse { + @Benchmark + def run(bs: BenchmarkState): Unit = { + runImpl(bs) + } +} + +@BenchmarkMode(Array(SampleTime)) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(value = 1, jvmArgs = Array("-Xms2G", "-Xmx2G")) +class WarmScalacParse extends ScalacParse { + @Benchmark + def run(bs: BenchmarkState): Unit = { + runImpl(bs) + } +} + +@BenchmarkMode(Array(SampleTime)) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Warmup(iterations = 10, time = 10, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 10, time = 10, timeUnit = TimeUnit.SECONDS) +@Fork(value = 3, jvmArgs = Array("-Xms2G", "-Xmx2G")) +class HotScalacParse extends ScalacParse { + @Benchmark + def run(bs: BenchmarkState): Unit = { + runImpl(bs) + } +} diff --git a/bench/scalac212/src/main/scala/rsc/bench/ScalacScan.scala b/bench/scalac212/src/main/scala/rsc/bench/ScalacScan.scala new file mode 100644 index 00000000..f10bd40c --- /dev/null +++ b/bench/scalac212/src/main/scala/rsc/bench/ScalacScan.scala @@ -0,0 +1,87 @@ +// Copyright (c) 2017 Twitter, Inc. +// Licensed under the Apache License, Version 2.0 (see LICENSE.md). +package rsc.bench + +import java.nio.file._ +import java.util.concurrent.TimeUnit +import org.openjdk.jmh.annotations._ +import org.openjdk.jmh.annotations.Mode._ +import scala.reflect.io._ +import scala.reflect.internal.util._ +import scala.tools.nsc._ +import scala.tools.nsc.ast.parser.Tokens._ +import scala.tools.nsc.reporters._ +import rsc.bench.ScalacScan._ + +object ScalacScan { + @State(Scope.Benchmark) + class BenchmarkState extends FileFixtures { + val settings = new Settings + settings.outdir.value = Files.createTempDirectory("scalac_").toString + settings.usejavacp.value = true + val reporter = new StoreReporter + val global = Global(settings, reporter) + val run = new global.Run + val abstractFiles = re2sScalacFiles.map(f => AbstractFile.getFile(f)) + val sourceFiles = abstractFiles.map(f => new BatchSourceFile(f)).toArray + } +} + +trait ScalacScan { + def runImpl(bs: BenchmarkState): Unit = { + var i = 0 + while (i < bs.sourceFiles.length) { + val sourceFile = bs.sourceFiles(i) + try { + val scanner = new bs.global.syntaxAnalyzer.SourceFileScanner(sourceFile) + scanner.init() + while (scanner.token != EOF) { + scanner.nextToken() + } + } catch { + case mi: bs.global.syntaxAnalyzer.MalformedInput => + val pos = Position.offset(sourceFile, mi.offset) + bs.reporter.error(pos, mi.msg) + } + i += 1 + } + if (bs.reporter.hasErrors) { + bs.reporter.infos.foreach(println) + sys.error("scan failed") + } + } +} + +@BenchmarkMode(Array(SingleShotTime)) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Fork(value = 128, jvmArgs = Array("-Xms2G", "-Xmx2G")) +class ColdScalacScan extends ScalacScan { + @Benchmark + def run(bs: BenchmarkState): Unit = { + runImpl(bs) + } +} + +@BenchmarkMode(Array(SampleTime)) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(value = 1, jvmArgs = Array("-Xms2G", "-Xmx2G")) +class WarmScalacScan extends ScalacScan { + @Benchmark + def run(bs: BenchmarkState): Unit = { + runImpl(bs) + } +} + +@BenchmarkMode(Array(SampleTime)) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Warmup(iterations = 10, time = 10, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 10, time = 10, timeUnit = TimeUnit.SECONDS) +@Fork(value = 3, jvmArgs = Array("-Xms2G", "-Xmx2G")) +class HotScalacScan extends ScalacScan { + @Benchmark + def run(bs: BenchmarkState): Unit = { + runImpl(bs) + } +} diff --git a/bench/scalac212/src/main/scala/rsc/bench/ScalacTypecheck.scala b/bench/scalac212/src/main/scala/rsc/bench/ScalacTypecheck.scala new file mode 100644 index 00000000..eeb64a98 --- /dev/null +++ b/bench/scalac212/src/main/scala/rsc/bench/ScalacTypecheck.scala @@ -0,0 +1,67 @@ +// Copyright (c) 2017 Twitter, Inc. +// Licensed under the Apache License, Version 2.0 (see LICENSE.md). +package rsc.bench + +import java.nio.file._ +import java.util.concurrent.TimeUnit +import org.openjdk.jmh.annotations._ +import org.openjdk.jmh.annotations.Mode._ +import scala.tools.nsc._ +import scala.tools.nsc.reporters._ +import rsc.bench.ScalacTypecheck._ + +object ScalacTypecheck { + @State(Scope.Benchmark) + class BenchmarkState extends FileFixtures +} + +trait ScalacTypecheck { + def runImpl(bs: BenchmarkState): Unit = { + val settings = new Settings + settings.outdir.value = Files.createTempDirectory("scalac_").toString + settings.stopAfter.value = List("typer") + settings.usejavacp.value = true + val reporter = new StoreReporter + val global = Global(settings, reporter) + val run = new global.Run + run.compile(bs.re2sScalacFiles.map(_.toString)) + if (reporter.hasErrors) { + reporter.infos.foreach(println) + sys.error("typecheck failed") + } + } +} + +@BenchmarkMode(Array(SingleShotTime)) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Fork(value = 128, jvmArgs = Array("-Xms2G", "-Xmx2G")) +class ColdScalacTypecheck extends ScalacTypecheck { + @Benchmark + def run(bs: BenchmarkState): Unit = { + runImpl(bs) + } +} + +@BenchmarkMode(Array(SampleTime)) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(value = 1, jvmArgs = Array("-Xms2G", "-Xmx2G")) +class WarmScalacTypecheck extends ScalacTypecheck { + @Benchmark + def run(bs: BenchmarkState): Unit = { + runImpl(bs) + } +} + +@BenchmarkMode(Array(SampleTime)) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Warmup(iterations = 10, time = 10, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 10, time = 10, timeUnit = TimeUnit.SECONDS) +@Fork(value = 3, jvmArgs = Array("-Xms2G", "-Xmx2G")) +class HotScalacTypecheck extends ScalacTypecheck { + @Benchmark + def run(bs: BenchmarkState): Unit = { + runImpl(bs) + } +} diff --git a/build.sbt b/build.sbt index d90d6c81..33aba29a 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,6 @@ val versions = new { - val scala = "2.11.11" + val scala211 = "2.11.11" + val scala212 = "2.12.4" val uTest = "0.6.0" } @@ -10,7 +11,7 @@ lazy val isCI = sys.props.getOrElse("CI", default = "false") == "true" lazy val commonSettings = Seq( organization := "org.twitter", version := version.value.replace("+", "-"), - scalaVersion := versions.scala, + scalaVersion := versions.scala211, scalacOptions ++= Seq("-Ypatmat-exhaust-depth", "off"), scalacOptions += "-deprecation", scalacOptions += "-unchecked", @@ -21,30 +22,50 @@ lazy val commonSettings = Seq( cancelable := true ) -lazy val bench = crossProject(JVMPlatform, NativePlatform) +lazy val benchSettings = commonSettings ++ Seq( + buildInfoPackage := "rsc.bench", + buildInfoUsePackageAsPath := true, + buildInfoKeys := Seq[BuildInfoKey]( + "sourceRoot" -> (baseDirectory in ThisBuild).value + ) +) + +lazy val benchJavac18 = project + .in(file("bench/javac18")) + .enablePlugins(BuildInfoPlugin) + .enablePlugins(JmhPlugin) + .settings(benchSettings) + +lazy val benchRsc = crossProject(JVMPlatform, NativePlatform) .crossType(CrossType.Full) - .in(file("bench")) - .dependsOn(rsc, tests) + .in(file("bench/rsc")) + .dependsOn(rsc) + .enablePlugins(BuildInfoPlugin) .enablePlugins(JmhPlugin) + .jvmSettings(benchCliRscNative("Typecheck")) + .settings(benchSettings) +lazy val benchRscJVM = benchRsc.jvm +lazy val benchRscNative = benchRsc.native + +lazy val benchScalac211 = project + .in(file("bench/scalac211")) .enablePlugins(BuildInfoPlugin) - .jvmSettings( - libraryDependencies += "org.scala-lang" % "scala-compiler" % versions.scala, - benchCliRscNative("Typecheck"), - benchCliRsc("Typecheck"), - benchCliScalac("Typecheck"), - benchCliScalac("Compile"), - benchCliJavac("Compile") + .enablePlugins(JmhPlugin) + .settings( + benchSettings, + scalaVersion := versions.scala211, + libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value ) + +lazy val benchScalac212 = project + .in(file("bench/scalac212")) + .enablePlugins(BuildInfoPlugin) + .enablePlugins(JmhPlugin) .settings( - commonSettings, - buildInfoPackage := "rsc.bench", - buildInfoUsePackageAsPath := true, - buildInfoKeys := Seq[BuildInfoKey]( - "sourceRoot" -> (baseDirectory in ThisBuild).value - ) + benchSettings, + scalaVersion := versions.scala212, + libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value ) -lazy val benchJVM = bench.jvm -lazy val benchNative = bench.native lazy val re2s = project .in(file("examples/re2s")) @@ -72,8 +93,7 @@ lazy val rscNative = rsc.native lazy val tests = crossProject(JVMPlatform, NativePlatform) .crossType(CrossType.Pure) .in(file("tests")) - .dependsOn(rsc) - .enablePlugins(BuildInfoPlugin) + .dependsOn(rsc, benchRsc) .jvmSettings( libraryDependencies += "com.lihaoyi" %% "utest" % versions.uTest, libraryDependencies += "com.lihaoyi" %% "utest" % versions.uTest % "test" @@ -86,17 +106,12 @@ lazy val tests = crossProject(JVMPlatform, NativePlatform) ) .settings( commonSettings, - testFrameworks += new TestFramework("utest.runner.Framework"), - buildInfoPackage := "rsc.tests", - buildInfoUsePackageAsPath := true, - buildInfoKeys := Seq[BuildInfoKey]( - "sourceRoot" -> (baseDirectory in ThisBuild).value - ) + testFrameworks += new TestFramework("utest.runner.Framework") ) lazy val testsJVM = tests.jvm lazy val testsNative = tests.native lazy val root = project .in(file(".")) - .aggregate(rscJVM, testsJVM, benchJVM) + .aggregate(rscJVM, testsJVM) .settings(commonSettings) diff --git a/docs/gettingstarted.md b/docs/gettingstarted.md index 428d7f0e..6397808c 100644 --- a/docs/gettingstarted.md +++ b/docs/gettingstarted.md @@ -67,10 +67,9 @@ an automated benchmark suite that can be invoked via `bench`. [info] Produced 54 files [info] Compiling to native code (1149 ms) [info] Linking native code (233 ms) -[info] Running rsc.bench.CliRscNativeTypecheck ~/Projects/rsc/bench/native/target/scala-2.11/benchnative-out +[info] Running rsc.bench.CliRscNativeTypecheck ~/Projects/rsc/bench/native/target/scala-2.11/benchrscnative-out ... -[info] Running org.openjdk.jmh.Main ColdRscTypecheck HotRscTypecheck ColdScalacTypecheck HotScalacTypecheck -ColdScalacCompile HotScalacCompile ColdJavacCompile HotScalacCompile +[info] Running org.openjdk.jmh.Main ColdRscTypecheck HotRscTypecheck [info] # JMH version: 1.19 [info] # VM version: JDK 1.8.0_111, VM 25.111-b14 [info] # VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre/bin/java diff --git a/project/Build.scala b/project/Build.scala index 8a7c9bd9..66d16718 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -19,60 +19,48 @@ object Build extends AutoPlugin { import autoImport._ object autoImport { def benchCliRscNative(bench: String) = { - val benchNative = ProjectRef(file("."), "benchNative") + val project = ProjectRef(file("."), "benchRscNative") val taskName = "benchCliRscNative" + bench val objectName = "rsc.bench.CliRscNative" + bench val taskKey = TaskKey[Unit](taskName) taskKey := (Def.taskDyn { - val _ = (nativeLink in Compile in benchNative).value - val exe = (artifactPath in nativeLink in Compile in benchNative).value + val _ = (nativeLink in Compile in project).value + val exe = (artifactPath in nativeLink in Compile in project).value (runMain in Compile).toTask(s" $objectName $exe") }).value } - def benchCliRsc(bench: String) = { - val benchJVM = ProjectRef(file("."), "benchJVM") - val taskName = "benchCliRsc" + bench - val objectName = "rsc.bench.CliRsc" + bench - val taskKey = TaskKey[Unit](taskName) - taskKey := (Def.taskDyn { - val attributeds = (fullClasspath in Compile in benchJVM).value - val filenames = attributeds.map(_.data.getAbsoluteFile.toString) - val classpath = filenames.mkString(java.io.File.pathSeparator) - (runMain in Compile).toTask(s" $objectName $classpath") - }).value - } - - def benchCliScalac(bench: String) = { - val bench = ProjectRef(file("."), "benchJVM") - val taskName = "benchCliScalac" + bench - val objectName = "rsc.bench.CliScalac" + bench - val taskKey = TaskKey[Unit](taskName) - taskKey := (Def.taskDyn { - val scalacVersion = (scalaVersion in bench).value.toString - (runMain in Compile).toTask(s" $objectName $scalacVersion") - }).value - } - - def benchCliJavac(bench: String) = { - val taskName = "benchCliJavac" + bench - val objectName = "rsc.bench.CliJavac" + bench - val taskKey = TaskKey[Unit](taskName) - taskKey := (Def.taskDyn { - val javacVersion = System.getProperty("java.version") - (runMain in Compile).toTask(s" $objectName $javacVersion") - }).value - } - object nightly { - val benchRscNativeTypecheck = "benchCliRscNativeTypecheck" - private val rscTyper = List("ColdRscTypecheck", "HotRscTypecheck") - private val scalaTyper = List("ColdScalacTypecheck", "HotScalacTypecheck") - private val scalaCompile = List("ColdScalacCompile", "HotScalacCompile") - private val javaCompile = List("ColdJavacCompile", "HotScalacCompile") - private val all = rscTyper ++ scalaTyper ++ scalaCompile ++ javaCompile - val benchRscScalacJavac = "benchJVM/jmh:run " + all.mkString(" ") - val benches = s"$benchRscNativeTypecheck ;$benchRscScalacJavac" + private val benchRscNative = "benchRscJVM/benchCliRscNativeTypecheck" + private val benchRsc = { + val typecheck = List("ColdRscTypecheck", "HotRscTypecheck") + val benches = typecheck + s"benchRscJVM/jmh:run ${benches.mkString(" ")}" + } + private def benchScalac(version: String) = { + val typecheck = List("ColdScalacTypecheck", "HotScalacTypecheck") + val compile = List("ColdScalacCompile", "HotScalacCompile") + val benches = typecheck ++ compile + s"benchScalac${version}/jmh:run ${benches.mkString(" ")}" + } + private val benchScalac211 = benchScalac("211") + private val benchScalac212 = benchScalac("212") + private val benchJavac18 = { + val javacVersion = classOf[Runtime].getPackage.getSpecificationVersion + if (javacVersion != "1.8") sys.error(s"unsupported JVM: $javacVersion") + val compile = List("ColdJavacCompile", "HotScalacCompile") + val benches = compile + s"benchJavac18/jmh:run ${benches.mkString(" ")}" + } + val benches = { + val commands = List( + benchRscNative, + benchRsc, + benchScalac211, + benchScalac212, + benchJavac18) + commands.mkString(" ;") + } } val scalafmtTest = taskKey[Unit]("Test formatting with Scalafmt") diff --git a/tests/src/main/scala/rsc/tests/RscFixtures.scala b/tests/src/main/scala/rsc/tests/RscFixtures.scala deleted file mode 100644 index 9c5dd68d..00000000 --- a/tests/src/main/scala/rsc/tests/RscFixtures.scala +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2017 Twitter, Inc. -// Licensed under the Apache License, Version 2.0 (see LICENSE.md). -package rsc.tests - -import java.io._ -import java.nio.file.Files -import scala.collection.JavaConverters._ -import rsc.Compiler -import rsc.report._ -import rsc.settings._ - -trait RscFixtures { - 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 - } - - lazy val re2sDir: File = { - new File(s"$buildRoot/examples/re2s/src/main/scala/java/util/regex") - } - - lazy val charGroupFile: File = { - new File(s"$re2sDir/CharGroup.scala") - } - - lazy val re2sFiles: 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") - } - - 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) - } -} diff --git a/tests/src/main/scala/rsc/tests/RscTests.scala b/tests/src/main/scala/rsc/tests/RscTests.scala index b9439a11..cfccbce5 100644 --- a/tests/src/main/scala/rsc/tests/RscTests.scala +++ b/tests/src/main/scala/rsc/tests/RscTests.scala @@ -3,11 +3,12 @@ package rsc.tests import utest._ +import rsc.bench._ import rsc.Compiler import rsc.report._ import rsc.syntax._ -trait RscTests extends TestSuite with RscFixtures { +trait RscTests extends TestSuite with RscFixtures with FileFixtures { def assertEquals[A](actual: A, expect: A): Unit = assert(actual == expect) diff --git a/tests/src/test/scala/rsc/parse/Re2sTests.scala b/tests/src/test/scala/rsc/parse/Re2sTests.scala index 19af9c2e..a4d7dccc 100644 --- a/tests/src/test/scala/rsc/parse/Re2sTests.scala +++ b/tests/src/test/scala/rsc/parse/Re2sTests.scala @@ -9,7 +9,7 @@ import rsc.tests._ object Re2sTests extends RscTests { val tests = Tests { "parse re2s" - { - val files1 = re2sFiles + val files1 = re2sRscFiles val compiler1 = mkCompiler("-Ystop-after:parse", files1) assertRun(compiler1) val trees1 = compiler1.trees diff --git a/tests/src/test/scala/rsc/typecheck/Re2sTests.scala b/tests/src/test/scala/rsc/typecheck/Re2sTests.scala index 404464c1..53a9dabe 100644 --- a/tests/src/test/scala/rsc/typecheck/Re2sTests.scala +++ b/tests/src/test/scala/rsc/typecheck/Re2sTests.scala @@ -8,7 +8,7 @@ import rsc.tests._ object Re2sTests extends RscTests { val tests = Tests { "typecheck re2s" - { - val compiler = mkCompiler("-Ystop-after:typecheck", re2sFiles) + val compiler = mkCompiler("-Ystop-after:typecheck", re2sRscFiles) assertRun(compiler) } }