aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/Bench.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-02-03 17:05:10 +0100
committerMartin Odersky <odersky@gmail.com>2014-02-03 17:05:10 +0100
commit16829831dcf417d7af409ecdd965b59b886921cd (patch)
treec6201ffc3b160f8022922e2caecacf36e1b119c5 /src/dotty/tools/dotc/Bench.scala
parent01fc1813929bfea3235bb0739131f675f57c7309 (diff)
downloaddotty-16829831dcf417d7af409ecdd965b59b886921cd.tar.gz
dotty-16829831dcf417d7af409ecdd965b59b886921cd.tar.bz2
dotty-16829831dcf417d7af409ecdd965b59b886921cd.zip
New benchmark class that allows tuning for #compilers and #runs
by command line options like #compilers 3 #runs 10 This would create one after another 3 compiler instances and perform 10 runs in each.
Diffstat (limited to 'src/dotty/tools/dotc/Bench.scala')
-rw-r--r--src/dotty/tools/dotc/Bench.scala20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/Bench.scala b/src/dotty/tools/dotc/Bench.scala
index 1fca7a2bb..4ac142683 100644
--- a/src/dotty/tools/dotc/Bench.scala
+++ b/src/dotty/tools/dotc/Bench.scala
@@ -22,23 +22,31 @@ object Bench extends Driver {
new compiler.Run() compile command.files
}*/
+ private var numRuns = 1
+
lazy val compiler = new Compiler
override def newCompiler(): Compiler = compiler
- override def doCompile(compiler: Compiler, fileNames: List[String])(implicit ctx: Context): Reporter = {
+ override def doCompile(compiler: Compiler, fileNames: List[String])(implicit ctx: Context): Reporter =
if (new config.Settings.Setting.SettingDecorator[Boolean](ctx.base.settings.resident).value(ctx))
resident(compiler)
else
- super.doCompile(compiler, fileNames)
- }
+ (emptyReporter /: (0 until numRuns))((_, _) => super.doCompile(compiler, fileNames))
- val N = 10
+ def extractNumArg(args: Array[String], name: String, default: Int = 1): (Int, Array[String]) = {
+ val pos = args indexOf name
+ if (pos < 0) (default, args)
+ else (args(pos + 1).toInt, (args take pos) ++ (args drop (pos + 2)))
+ }
override def main(args: Array[String]): Unit = {
- for (i <- 0 until N) {
+ val (numCompilers, args1) = extractNumArg(args, "#compilers")
+ val (numRuns, args2) = extractNumArg(args1, "#runs")
+ this.numRuns = numRuns
+ for (i <- 0 until numCompilers) {
val start = System.nanoTime()
- process(args)
+ process(args2)
println(s"time elapsed: ${(System.nanoTime - start) / 1000000}ms")
}
}