@@ -11,14 +11,20 @@ import scala.io.Source
11
11
12
12
object Bench {
13
13
def main (args : Array [String ]): Unit = {
14
+ if (args.contains(" --help" )) {
15
+ printUsage()
16
+ return
17
+ }
18
+
14
19
val (intArgs, args1) = args.span(x => try { x.toInt; true } catch { case _ : Throwable => false } )
15
20
16
21
val warmup = if (intArgs.length > 0 ) intArgs(0 ).toInt else 20
17
22
val iterations = if (intArgs.length > 1 ) intArgs(1 ).toInt else 20
18
23
val forks = if (intArgs.length > 2 ) intArgs(2 ).toInt else 1
19
24
20
25
if (args1.isEmpty) {
21
- println(" You should specify which benchmarks to run." )
26
+ println(" Error: no benchmark was specified." )
27
+ printUsage()
22
28
return
23
29
}
24
30
@@ -36,16 +42,16 @@ object Bench {
36
42
.resultFormat(ResultFormatType .CSV )
37
43
38
44
if (args1.length > 1 && args1(1 ) != " --" ) {
39
- for ((param, values) <- paramsFromFile(args1(1 )))
45
+ for ((param, values) <- paramsFromFile(" inputs/ " ++ args1(1 )))
40
46
builder = builder.param(param, values : _* )
41
47
}
42
48
43
49
if (args1.length > 2 ) {
44
50
builder = builder.result(args1(2 ))
45
51
}
46
52
47
- val runner = new Runner (builder.build) // full access to all JMH features, you can also provide a custom output Format here
48
- runner.run // actually run the benchmarks
53
+ val runner = new Runner (builder.build)
54
+ runner.run
49
55
}
50
56
51
57
def paramsFromFile (file : String ): Array [(String , Array [String ])] = {
@@ -54,4 +60,19 @@ object Bench {
54
60
(param, values split ',' )
55
61
}
56
62
}
63
+
64
+ def printUsage (): Unit = {
65
+ println()
66
+ println(" Usage:" )
67
+ println()
68
+ println(" dotty-bench-run/jmh:run [<warmup>] [<iterations>] [<forks>] <regexp> [<input>|--] [<output>]" )
69
+ println()
70
+ println(" warmup: warmup iterations. defaults to 20." )
71
+ println(" iterations: benchmark iterations. defaults to 20." )
72
+ println(" forks: number of forks. defaults to 1." )
73
+ println(" regexp: regular expression that selects which benchmarks to run." )
74
+ println(" input: input vector file. each line should have format \' <paramName>: <comma-separated-values>\' " )
75
+ println(" output: output file for the results of benchmarks." )
76
+ println()
77
+ }
57
78
}
0 commit comments