@@ -2,6 +2,8 @@ package dotty.tools.benchmarks
22
33import dotty .tools .dotc ._
44import core .Contexts .Context
5+ import dotty .tools .FatalError
6+ import reporting ._
57
68import org .openjdk .jmh .results .RunResult
79import org .openjdk .jmh .runner .Runner
@@ -34,10 +36,9 @@ object Bench {
3436 }
3537 storeCompileOptions(args2)
3638
37- val libs = System .getProperty(" BENCH_CLASS_PATH" )
38-
3939 val opts = new OptionsBuilder ()
40- .jvmArgsPrepend(s " -classpath $libs" , " -Xms2G" , " -Xmx2G" )
40+ .shouldFailOnError(true )
41+ .jvmArgs(" -Xms2G" , " -Xmx2G" )
4142 .mode(Mode .AverageTime )
4243 .timeUnit(TimeUnit .MILLISECONDS )
4344 .warmupIterations(warmup)
@@ -54,9 +55,20 @@ object Bench {
5455 def removeCompileOptions : Unit = new File (COMPILE_OPTS_FILE ).delete()
5556
5657 def storeCompileOptions (args : Array [String ]): Unit = {
58+ val standard_libs = System .getProperty(" BENCH_CLASS_PATH" )
59+ val compiler_libs = System .getProperty(" BENCH_COMPILER_CLASS_PATH" )
60+
61+ val libs = if (args.contains(" -with-compiler" )) compiler_libs else standard_libs
62+ var argsNorm = args.filter(_ != " -with-compiler" )
63+
64+ var cpIndex = argsNorm.indexOf(" -classpath" )
65+ if (cpIndex == - 1 ) cpIndex = argsNorm.indexOf(" -cp" )
66+ if (cpIndex != - 1 ) argsNorm(cpIndex + 1 ) = argsNorm(cpIndex + 1 ) + " :" + libs
67+ else argsNorm = argsNorm :+ " -classpath" :+ libs
68+
5769 val file = new File (COMPILE_OPTS_FILE )
5870 val bw = new BufferedWriter (new FileWriter (file))
59- bw.write(args .mkString(" \n " ))
71+ bw.write(argsNorm .mkString(" " , " \n " , " \n " ))
6072 bw.close()
6173 }
6274
@@ -75,6 +87,21 @@ class CompilerOptions {
7587}
7688
7789class Worker extends Driver {
90+ // override to avoid printing summary information
91+ override def doCompile (compiler : Compiler , fileNames : List [String ])(implicit ctx : Context ): Reporter =
92+ if (fileNames.nonEmpty)
93+ try {
94+ val run = compiler.newRun
95+ run.compile(fileNames)
96+ ctx.reporter
97+ }
98+ catch {
99+ case ex : FatalError =>
100+ ctx.error(ex.getMessage) // signals that we should fail compilation.
101+ ctx.reporter
102+ }
103+ else ctx.reporter
104+
78105 @ Benchmark
79106 def compile (state : CompilerOptions ): Unit = {
80107 val res = process(state.opts)
0 commit comments