1 package org.openjdk.bench.vm.gc.barriers.reads;
 2 
 3 import org.openjdk.jmh.annotations.*;
 4 
 5 import java.util.concurrent.TimeUnit;
 6 
 7 @Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
 8 @Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
 9 @Fork(3)
10 @BenchmarkMode(Mode.AverageTime)
11 @OutputTimeUnit(TimeUnit.NANOSECONDS)
12 @State(Scope.Thread)
13 public class SingleVolatile {
14 
15     Target src;
16 
17     @Setup
18     public void setup() {
19         src = new Target();
20     }
21 
22     @Benchmark
23     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
24     public Object test_ref() {
25         return src.f_Object;
26     }
27 
28     @Benchmark
29     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
30     public int test_int() {
31         return src.f_int;
32     }
33 
34     static class Target {
35         volatile int f_int;
36         volatile Object f_Object;
37     }
38 
39 }