I've an ArrayList of 50M, I would like to measure time it takes to store that many objects in it. It seems as all JMH modes are time based, we can't really control number of executions of code under @Benchmark. For examlpe, how can I ensure the following code is run exactly 50M times per fork?
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Fork(5)
public void run(BenchmarkState state) {
try {
state.queue.add(System.nanoTime());
} catch (Exception e) {
e.printStackTrace();
}
}