summaryrefslogtreecommitdiff
path: root/test/benchmarks
diff options
context:
space:
mode:
authorPerformant Data LLC <performantdata@users.noreply.github.com>2016-03-28 13:54:43 -0700
committerPerformant Data LLC <performantdata@users.noreply.github.com>2016-05-03 11:46:58 -0700
commitcd7be12a35fd2cf7d0448d59b6f43e4165f43db4 (patch)
treed823a719a8f9bc6337d7c5c4066934b2bcb3cb55 /test/benchmarks
parent2e8fb12f6d92e6021131461285b9c28909584d04 (diff)
downloadscala-cd7be12a35fd2cf7d0448d59b6f43e4165f43db4.tar.gz
scala-cd7be12a35fd2cf7d0448d59b6f43e4165f43db4.tar.bz2
scala-cd7be12a35fd2cf7d0448d59b6f43e4165f43db4.zip
Improve the OpenHashMapBenchmark run times.
For the warm-up invocations, suppress setup and teardown that is only needed for the measurement iterations. Reduce the number of forks.
Diffstat (limited to 'test/benchmarks')
-rw-r--r--test/benchmarks/src/main/scala/scala/collection/mutable/OpenHashMapBenchmark.scala21
1 files changed, 14 insertions, 7 deletions
diff --git a/test/benchmarks/src/main/scala/scala/collection/mutable/OpenHashMapBenchmark.scala b/test/benchmarks/src/main/scala/scala/collection/mutable/OpenHashMapBenchmark.scala
index 13be9e6206..78e160a713 100644
--- a/test/benchmarks/src/main/scala/scala/collection/mutable/OpenHashMapBenchmark.scala
+++ b/test/benchmarks/src/main/scala/scala/collection/mutable/OpenHashMapBenchmark.scala
@@ -7,6 +7,8 @@ import org.openjdk.jmh.infra.BenchmarkParams
import org.openjdk.jol.info.GraphLayout
import org.openjdk.jol.info.GraphWalker
import org.openjdk.jol.info.GraphVisitor
+import org.openjdk.jmh.infra.IterationParams
+import org.openjdk.jmh.runner.IterationType
/** Utilities for the [[OpenHashMapBenchmark]].
*
@@ -61,16 +63,21 @@ private object OpenHashMapBenchmark {
}
@Setup(Level.Invocation)
- def setup {
+ def setup(params: IterationParams) {
for (i <- 0 until maps.length) maps(i) = new OpenHashMap[Int,Int](size)
- operations += mapEntries
- System.gc() // clean up after last invocation
+
+ if (params.getType == IterationType.MEASUREMENT) {
+ operations += mapEntries
+ System.gc() // clean up after last invocation
+ }
}
@TearDown(Level.Iteration)
- def iterationTeardown {
- // limit to smaller cases to avoid OOM
- memory = if (mapEntries <= 1000000) GraphLayout.parseInstance(maps(0), maps.tail).totalSize else 0
+ def iterationTeardown(params: IterationParams) {
+ if (params.getType == IterationType.MEASUREMENT) {
+ // limit to smaller cases to avoid OOM
+ memory = if (mapEntries <= 1000000) GraphLayout.parseInstance(maps(0), maps.tail).totalSize else 0
+ }
}
}
@@ -154,7 +161,7 @@ private object OpenHashMapBenchmark {
/** Benchmark for the library's [[OpenHashMap]]. */
@BenchmarkMode(Array(Mode.AverageTime))
-@Fork(10)
+@Fork(6)
@Threads(1)
@Warmup(iterations = 20)
@Measurement(iterations = 6)