Mercurial > hg > gc-bench
changeset 63:4016779f803c
A bit more WIP work.
author | shade |
---|---|
date | Thu, 05 Jan 2017 13:12:38 +0100 |
parents | 04bf515935c1 |
children | 4b6fa8cb7422 |
files | src/main/java/org/openjdk/gcbench/wip/ReadBarriersCountedLoop.java src/main/java/org/openjdk/gcbench/wip/ReadWriteBarrierMerge.java |
diffstat | 2 files changed, 65 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/wip/ReadBarriersCountedLoop.java Thu Jan 05 13:12:38 2017 +0100 @@ -0,0 +1,41 @@ +package org.openjdk.gcbench.wip; + +import org.openjdk.jmh.annotations.*; + +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(1) +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@Threads(1) +@State(Scope.Benchmark) +public class ReadBarriersCountedLoop { + + @Param({"1", "10", "100", "1000", "10000"}) + int count; + + byte[] x; + + @Setup + public void setup() { + x = new byte[count]; + for (int c = 0; c < count; c++) { + x[c] = 42; + } + } + + @Benchmark + public int test() { + int r = 0; + for (int c = 0; c < count; c++) { + r += x[c]; + } + return r; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/org/openjdk/gcbench/wip/ReadWriteBarrierMerge.java Thu Jan 05 13:12:38 2017 +0100 @@ -0,0 +1,24 @@ +package org.openjdk.gcbench.wip; + +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(1) +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@Threads(1) +@State(Scope.Benchmark) +public class ReadWriteBarrierMerge { + + double x; + + @Benchmark + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void test() { + x++; + } + +}