package test; import org.openjdk.jmh.annotations.*; /** * @author bourgesl */ @State(Scope.Thread) public class AAShapePipeBenchmark { int size = 4; /** * Per-thread RendererContexts */ ThreadLocal contextThreadLocal = new ThreadLocal() { @Override protected AAShapePipeContext initialValue() { return new AAShapePipeContext(); } }; final static class AAShapePipeContext { final int[] abox = new int[4]; } @GenerateMicroBenchmark public int[] testSimpleArray() { int abox[] = new int[size]; abox[0] = 7; abox[1] = 11; abox[2] = 13; abox[3] = 17; return abox; } @GenerateMicroBenchmark public int[] testTCArray() { AAShapePipeContext ctx = contextThreadLocal.get(); int abox[] = ctx.abox; abox[0] = 7; abox[1] = 11; abox[2] = 13; abox[3] = 17; return abox; } }