Mercurial > hg > gc-bench
changeset 56:c796a662ffba
Basic tenure tests.
author | shade |
---|---|
date | Mon, 19 Dec 2016 17:23:14 +0100 |
parents | 27585a7e9a03 |
children | 1655f5729b5a |
files | src/main/java/org/openjdk/gcbench/tenure/Arrays.java src/main/java/org/openjdk/gcbench/tenure/Queues.java |
diffstat | 2 files changed, 78 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/org/openjdk/gcbench/tenure/Arrays.java Mon Dec 19 17:23:14 2016 +0100 @@ -0,0 +1,40 @@ +package org.openjdk.gcbench.tenure; + +import org.openjdk.gcbench.alloc.uninit.AllocUninit; +import org.openjdk.jmh.annotations.*; + +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(jvmArgsPrepend = {"--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED"}) +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@Threads(Threads.MAX) +@State(Scope.Thread) +public class Arrays { + + Object[] tenures; + + @Param({"100000"}) + int size; + + int idx; + + @Setup + public void setup() { + tenures = new Object[size]; + } + + @Benchmark + public void test() { + int cur = idx; + tenures[cur] = AllocUninit.alloc(1000); + if (cur + 1 < size) { + idx = cur + 1; + } else { + idx = 0; + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/org/openjdk/gcbench/tenure/Queues.java Mon Dec 19 17:23:14 2016 +0100 @@ -0,0 +1,38 @@ +package org.openjdk.gcbench.tenure; + +import org.openjdk.gcbench.alloc.uninit.AllocUninit; +import org.openjdk.jmh.annotations.*; + +import java.util.concurrent.ConcurrentLinkedDeque; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(jvmArgsPrepend = {"--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED"}) +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@Threads(Threads.MAX) +@State(Scope.Benchmark) +public class Queues { + + ConcurrentLinkedQueue<Object> tenures; + + @Param({"100000"}) + int size; + + @Setup + public void setup() { + tenures = new ConcurrentLinkedQueue<>(); + for (int c = 0; c < size; c++) { + tenures.add(new byte[64]); + } + } + + @Benchmark + public Object test() { + tenures.add(new byte[64]); + return tenures.poll(); + } + +}