Mercurial > hg > gc-bench
view src/main/java/org/openjdk/gcbench/wip/ReadBarriersCountedLoop.java @ 63:4016779f803c
A bit more WIP work.
author | shade |
---|---|
date | Thu, 05 Jan 2017 13:12:38 +0100 |
parents | src/main/java/org/openjdk/gcbench/wip/WeakRefs.java@f8496889e1ac |
children | 583fef4276f5 |
line wrap: on
line source
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; } }