@@ -11,14 +11,20 @@ import scala.io.Source
1111
1212object Bench {
1313 def main (args : Array [String ]): Unit = {
14+ if (args.contains(" --help" )) {
15+ printUsage()
16+ return
17+ }
18+
1419 val (intArgs, args1) = args.span(x => try { x.toInt; true } catch { case _ : Throwable => false } )
1520
1621 val warmup = if (intArgs.length > 0 ) intArgs(0 ).toInt else 20
1722 val iterations = if (intArgs.length > 1 ) intArgs(1 ).toInt else 20
1823 val forks = if (intArgs.length > 2 ) intArgs(2 ).toInt else 1
1924
2025 if (args1.isEmpty) {
21- println(" You should specify which benchmarks to run." )
26+ println(" Error: no benchmark was specified." )
27+ printUsage()
2228 return
2329 }
2430
@@ -36,16 +42,16 @@ object Bench {
3642 .resultFormat(ResultFormatType .CSV )
3743
3844 if (args1.length > 1 && args1(1 ) != " --" ) {
39- for ((param, values) <- paramsFromFile(args1(1 )))
45+ for ((param, values) <- paramsFromFile(" inputs/ " ++ args1(1 )))
4046 builder = builder.param(param, values : _* )
4147 }
4248
4349 if (args1.length > 2 ) {
4450 builder = builder.result(args1(2 ))
4551 }
4652
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
4955 }
5056
5157 def paramsFromFile (file : String ): Array [(String , Array [String ])] = {
@@ -54,4 +60,19 @@ object Bench {
5460 (param, values split ',' )
5561 }
5662 }
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+ }
5778}
0 commit comments