@@ -5,14 +5,10 @@ import core.Contexts.Context
55
66import org .openjdk .jmh .results .RunResult
77import org .openjdk .jmh .runner .Runner
8- import org .openjdk .jmh .runner .options .CommandLineOptions
9- import org .openjdk .jmh .annotations .Benchmark
10- import org .openjdk .jmh .annotations .State
11- import org .openjdk .jmh .annotations .Scope
12-
13- import org .openjdk .jmh .annotations .Setup
14- import org .openjdk .jmh .annotations .TearDown
15-
8+ import org .openjdk .jmh .runner .options .OptionsBuilder
9+ import org .openjdk .jmh .annotations ._
10+ import org .openjdk .jmh .results .format ._
11+ import java .util .concurrent .TimeUnit
1612
1713import java .io .{File , FileOutputStream , BufferedWriter , FileWriter }
1814import scala .collection .JavaConversions ._
@@ -24,21 +20,27 @@ object Bench {
2420 def main (args : Array [String ]): Unit = {
2521 storeCompileOptions(args)
2622
27- val opts = new CommandLineOptions () // parse command line arguments, and then bend them to your will! ;-)
28- val runner = new Runner (opts) // full access to all JMH features, you can also provide a custom output Format here
23+ val libs = System .getenv(" BOOTSTRAP_APPEND" )
2924
30- /*
31- val results = runner.run() // actually run the benchmarks
25+ val opts = new OptionsBuilder ()
26+ .jvmArgsPrepend(s " -Xbootclasspath/a: $libs" )
27+ .mode(Mode .AverageTime )
28+ .timeUnit(TimeUnit .MICROSECONDS )
29+ .forks(5 )
30+ .warmupIterations(5 )
31+ .measurementIterations(10 )
32+ .resultFormat(ResultFormatType .CSV )
33+ .result(" result.csv" )
34+ .build
3235
33- val f = new FileOutputStream(new File("custom.out"))
34- results.foreach { result: RunResult ⇒
35- // usually you'd use these results to report into some external aggregation tool for example
36- f.write(s"custom reporting result: ${result.getAggregatedResult.getPrimaryResult}".getBytes("UTF-8"))
37- }
38- f.close()
39- */
36+ val runner = new Runner (opts) // full access to all JMH features, you can also provide a custom output Format here
37+ runner.run() // actually run the benchmarks
38+
39+ removeCompileOptions
4040 }
4141
42+ def removeCompileOptions : Unit = new File (COMPILE_OPTS_FILE ).delete()
43+
4244 def storeCompileOptions (args : Array [String ]): Unit = {
4345 val file = new File (COMPILE_OPTS_FILE )
4446 val bw = new BufferedWriter (new FileWriter (file))
@@ -65,7 +67,7 @@ class Worker extends Driver {
6567
6668 @ Benchmark
6769 def compile (state : CompilerOptions ): Unit = {
68- println( " options: " + state.opts.mkString( " , " ) )
69- super .main(state.opts )
70+ val res = process( state.opts)
71+ if (res.hasErrors) throw new Exception ( " compilation failed " )
7072 }
7173}
0 commit comments