Benchmark keeps running
Yann Le Tallec
ylt at letallec.org
Tue May 7 20:21:39 PDT 2013
Hello,
I am probably missing something obvious but the bechmark below only works
with one thread. When using 2 or more threads, it gets stuck during the
first warmup iteration.
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public class CAS {
@State(Scope.Benchmark)
public static class AIState {
private final AtomicInteger ai = new AtomicInteger();
}
@GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
public int cas(CAS.AIState state) {
int i = state.ai.get();
while (!state.ai.compareAndSet(i, i + 1)) { }
return state.ai.get();
}
}
I run it with: java -jar microbenchmarks.jar ".*CAS.*" -wi 5 -w 200ms -i 5
-r 200ms -t 1
(and -t 2 for 2 threads respectively).
Many thanks,
Yann
More information about the jmh-dev
mailing list