1 package org.openjdk.bench.vm.gc.barriers.clone;
 2 
 3 import org.openjdk.jmh.annotations.*;
 4 
 5 import java.util.concurrent.TimeUnit;
 6 
 7 @Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
 8 @Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
 9 @Fork(value = 3, jvmArgs = {"-Xmx8g", "-Xms8g"})
10 @BenchmarkMode(Mode.AverageTime)
11 @OutputTimeUnit(TimeUnit.NANOSECONDS)
12 @State(Scope.Thread)
13 public class RefArray {
14 
15     Object[] srcNull;
16     Object[] srcObj;
17 
18     @Param({"1", "4", "16", "64", "256", "1024"})
19     int size;
20 
21     @Setup
22     public void setup() {
23         srcNull = new Object[size];
24         srcObj = new Object[size];
25         for (int c = 0; c < size; c++) {
26             srcObj[c] = new Object();
27         }
28     }
29 
30     @Benchmark
31     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
32     public Object[] objs() {
33         return srcObj.clone();
34     }
35 
36     @Benchmark
37     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
38     public Object[] nulls() {
39         return srcNull.clone();
40     }
41 
42 }