@@ -5,14 +5,10 @@ import core.Contexts.Context
5
5
6
6
import org .openjdk .jmh .results .RunResult
7
7
import 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
16
12
17
13
import java .io .{File , FileOutputStream , BufferedWriter , FileWriter }
18
14
import scala .collection .JavaConversions ._
@@ -24,21 +20,27 @@ object Bench {
24
20
def main (args : Array [String ]): Unit = {
25
21
storeCompileOptions(args)
26
22
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" )
29
24
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
32
35
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
40
40
}
41
41
42
+ def removeCompileOptions : Unit = new File (COMPILE_OPTS_FILE ).delete()
43
+
42
44
def storeCompileOptions (args : Array [String ]): Unit = {
43
45
val file = new File (COMPILE_OPTS_FILE )
44
46
val bw = new BufferedWriter (new FileWriter (file))
@@ -65,7 +67,7 @@ class Worker extends Driver {
65
67
66
68
@ Benchmark
67
69
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 " )
70
72
}
71
73
}
0 commit comments