@@ -2,6 +2,8 @@ package dotty.tools.benchmarks
2
2
3
3
import dotty .tools .dotc ._
4
4
import core .Contexts .Context
5
+ import dotty .tools .FatalError
6
+ import reporting ._
5
7
6
8
import org .openjdk .jmh .results .RunResult
7
9
import org .openjdk .jmh .runner .Runner
@@ -34,10 +36,9 @@ object Bench {
34
36
}
35
37
storeCompileOptions(args2)
36
38
37
- val libs = System .getProperty(" BENCH_CLASS_PATH" )
38
-
39
39
val opts = new OptionsBuilder ()
40
- .jvmArgsPrepend(s " -classpath $libs" , " -Xms2G" , " -Xmx2G" )
40
+ .shouldFailOnError(true )
41
+ .jvmArgs(" -Xms2G" , " -Xmx2G" )
41
42
.mode(Mode .AverageTime )
42
43
.timeUnit(TimeUnit .MILLISECONDS )
43
44
.warmupIterations(warmup)
@@ -54,9 +55,20 @@ object Bench {
54
55
def removeCompileOptions : Unit = new File (COMPILE_OPTS_FILE ).delete()
55
56
56
57
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
+
57
69
val file = new File (COMPILE_OPTS_FILE )
58
70
val bw = new BufferedWriter (new FileWriter (file))
59
- bw.write(args .mkString(" \n " ))
71
+ bw.write(argsNorm .mkString(" " , " \n " , " \n " ))
60
72
bw.close()
61
73
}
62
74
@@ -75,6 +87,21 @@ class CompilerOptions {
75
87
}
76
88
77
89
class 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
+
78
105
@ Benchmark
79
106
def compile (state : CompilerOptions ): Unit = {
80
107
val res = process(state.opts)
0 commit comments