diff options
author | Martin Odersky <odersky@gmail.com> | 2016-12-14 14:37:13 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-12-17 18:34:27 +0100 |
commit | 04adb53b8d079ea114c5432ca3b3f824c80756a7 (patch) | |
tree | 5a21d3570dd5b5d2d70805a4d2266f0c7f943264 /tests/bench/transactional/Runner.scala | |
parent | 30faa7b5e2dee0e2b80fe2c7696df20537644d74 (diff) | |
download | dotty-04adb53b8d079ea114c5432ca3b3f824c80756a7.tar.gz dotty-04adb53b8d079ea114c5432ca3b3f824c80756a7.tar.bz2 dotty-04adb53b8d079ea114c5432ca3b3f824c80756a7.zip |
Add benchmarks
Benchmark code to compare compilation schemes in
different scenarios. See results.md for explanations.
Diffstat (limited to 'tests/bench/transactional/Runner.scala')
-rw-r--r-- | tests/bench/transactional/Runner.scala | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/bench/transactional/Runner.scala b/tests/bench/transactional/Runner.scala new file mode 100644 index 000000000..48da7ff12 --- /dev/null +++ b/tests/bench/transactional/Runner.scala @@ -0,0 +1,25 @@ +package transactional +import System.nanoTime + +class Runner(name: String, bench: Benchmark, expected: Int) { + + val numIters = 10000000 + val numTests = 5 + + def run(): Unit = { + val start = nanoTime + var cnt = 0 + var i = 0 + while (i < numIters) { + cnt += bench.run() + i += 1 + } + assert(cnt == expected * numIters) + val duration = nanoTime - start + println(s"$name in ${duration / 1000000}ms") + } + + def main(args: Array[String]) = + for (i <- 0 until numTests) + run() +} |