Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JMH Problem with Inline Control in 0.3.1
quiet
dontinline,net/eckenfels/tests/jmh/SingletonAccess.measureAtomicNI
dontinline,net/eckenfels/tests/jmh/SingletonAccess.measureFieldNI
dontinline,net/eckenfels/tests/jmh/SingletonAccess.measureSyncNI
dontinline,net/eckenfels/tests/jmh/SingletonAccess.measureVolatileNI
dontinline,net/eckenfels/tests/jmh/generated/SingletonAccess.*
exclude,net/eckenfels/tests/jmh/SingletonAccess.measureVolatileE
inline,net/eckenfels/tests/jmh/SingletonAccess.measureAtomicI
inline,net/eckenfels/tests/jmh/SingletonAccess.measureFieldI
inline,net/eckenfels/tests/jmh/SingletonAccess.measureSyncI
inline,net/eckenfels/tests/jmh/SingletonAccess.measureVolatileI
quiet
inline,org/openjdk/jmh/logic/BlackHole.*
dontinline,net/eckenfels/tests/jmh/SingletonAccess.measureAtomicNI
dontinline,net/eckenfels/tests/jmh/SingletonAccess.measureFieldNI
dontinline,net/eckenfels/tests/jmh/SingletonAccess.measureSyncNI
dontinline,net/eckenfels/tests/jmh/SingletonAccess.measureVolatileNI
dontinline,net/eckenfels/tests/jmh/generated/SingletonAccess_.*
exclude,net/eckenfels/tests/jmh/SingletonAccess.measureVolatileE
inline,net/eckenfels/tests/jmh/SingletonAccess.measureAtomicI
inline,net/eckenfels/tests/jmh/SingletonAccess.measureAtomicNI
inline,net/eckenfels/tests/jmh/SingletonAccess.measureFieldI
inline,net/eckenfels/tests/jmh/SingletonAccess.measureFieldNI
inline,net/eckenfels/tests/jmh/SingletonAccess.measureSyncI
inline,net/eckenfels/tests/jmh/SingletonAccess.measureSyncNI
inline,net/eckenfels/tests/jmh/SingletonAccess.measureVolatile
inline,net/eckenfels/tests/jmh/SingletonAccess.measureVolatileE
inline,net/eckenfels/tests/jmh/SingletonAccess.measureVolatileI
inline,net/eckenfels/tests/jmh/SingletonAccess.measureVolatileNI
# Fork: 1 of 1
# Warmup: 3 iterations, 1 s each
# Measurement: 3 iterations, 1 s each
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Running: net.eckenfels.tests.jmh.SingletonAccess.measureVolatile
# Warmup Iteration 1: 169,568 ops/us
# Warmup Iteration 2: 172,258 ops/us
# Warmup Iteration 3: 174,043 ops/us
Iteration 1: 172,885 ops/us
Iteration 2: 172,991 ops/us
Iteration 3: 172,693 ops/us
Result : 172,856 ±(99.9%) 1,945 ops/us
Statistics: (min, avg, max) = (172,693, 172,856, 172,991), stdev = 0,151
Confidence interval (99.9%): [170,911, 174,802]
# Fork: 1 of 1
# Warmup: 3 iterations, 1 s each
# Measurement: 3 iterations, 1 s each
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Running: net.eckenfels.tests.jmh.SingletonAccess.measureVolatileE
# Warmup Iteration 1: 11,765 ops/us
# Warmup Iteration 2: 11,809 ops/us
# Warmup Iteration 3: 12,100 ops/us
Iteration 1: 12,193 ops/us
Iteration 2: 12,110 ops/us
Iteration 3: 12,140 ops/us
Result : 12,148 ±(99.9%) 0,540 ops/us
Statistics: (min, avg, max) = (12,110, 12,148, 12,193), stdev = 0,042
Confidence interval (99.9%): [11,608, 12,688]
# Fork: 1 of 1
# Warmup: 3 iterations, 1 s each
# Measurement: 3 iterations, 1 s each
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Running: net.eckenfels.tests.jmh.SingletonAccess.measureVolatileI
# Warmup Iteration 1: 170,275 ops/us
# Warmup Iteration 2: 173,631 ops/us
# Warmup Iteration 3: 174,372 ops/us
Iteration 1: 173,276 ops/us
Iteration 2: 171,086 ops/us
Iteration 3: 172,899 ops/us
Result : 172,420 ±(99.9%) 15,093 ops/us
Statistics: (min, avg, max) = (171,086, 172,420, 173,276), stdev = 1,171
Confidence interval (99.9%): [157,327, 187,514]
# Fork: 1 of 1
# Warmup: 3 iterations, 1 s each
# Measurement: 3 iterations, 1 s each
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Running: net.eckenfels.tests.jmh.SingletonAccess.measureVolatileNI
# Warmup Iteration 1: 95,524 ops/us
# Warmup Iteration 2: 96,656 ops/us
# Warmup Iteration 3: 103,167 ops/us
Iteration 1: 103,475 ops/us
Iteration 2: 104,108 ops/us
Iteration 3: 102,296 ops/us
Result : 103,293 ±(99.9%) 11,850 ops/us
Statistics: (min, avg, max) = (102,296, 103,293, 104,108), stdev = 0,919
Confidence interval (99.9%): [91,443, 115,143]
Benchmark Mode Samples Mean Mean error Units
n.e.t.j.SingletonAccess.measureVolatile thrpt 3 172,856 1,945 ops/us
n.e.t.j.SingletonAccess.measureVolatileE thrpt 3 12,148 0,540 ops/us
n.e.t.j.SingletonAccess.measureVolatileI thrpt 3 172,420 15,093 ops/us
n.e.t.j.SingletonAccess.measureVolatileNI thrpt 3 103,293 11,850 ops/us
"$JAVA" -jar target/microbenchmarks.jar ".*Volatile.*" -wi 3 -i 3 -f 1 -o result031.txt
# Run progress: 0,00% complete, ETA 00:00:24
# VM invoker: c:\Program Files\Java\jdk1.7.0_51\jre\bin\java.exe
# VM options: <none>
# Fork: 1 of 1
# Warmup: 3 iterations, 1 s each
# Measurement: 3 iterations, 1 s each
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: net.eckenfels.tests.jmh.SingletonAccess.measureVolatile
# Warmup Iteration 1: 168,368 ops/us
# Warmup Iteration 2: 172,238 ops/us
# Warmup Iteration 3: 173,446 ops/us
Iteration 1: 172,304 ops/us
Iteration 2: 173,756 ops/us
Iteration 3: 172,414 ops/us
Result : 172,825 ±(99.9%) 14,753 ops/us
Statistics: (min, avg, max) = (172,304, 172,825, 173,756), stdev = 0,809
Confidence interval (99.9%): [158,071, 187,578]
# Run progress: 25,00% complete, ETA 00:00:19
# VM invoker: c:\Program Files\Java\jdk1.7.0_51\jre\bin\java.exe
# VM options: <none>
# Fork: 1 of 1
# Warmup: 3 iterations, 1 s each
# Measurement: 3 iterations, 1 s each
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: net.eckenfels.tests.jmh.SingletonAccess.measureVolatileE
# Warmup Iteration 1: 12,764 ops/us
# Warmup Iteration 2: 12,829 ops/us
# Warmup Iteration 3: 12,613 ops/us
Iteration 1: 12,546 ops/us
Iteration 2: 12,467 ops/us
Iteration 3: 12,657 ops/us
Result : 12,557 ±(99.9%) 1,744 ops/us
Statistics: (min, avg, max) = (12,467, 12,557, 12,657), stdev = 0,096
Confidence interval (99.9%): [10,813, 14,301]
# Run progress: 50,00% complete, ETA 00:00:12
# VM invoker: c:\Program Files\Java\jdk1.7.0_51\jre\bin\java.exe
# VM options: <none>
# Fork: 1 of 1
# Warmup: 3 iterations, 1 s each
# Measurement: 3 iterations, 1 s each
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: net.eckenfels.tests.jmh.SingletonAccess.measureVolatileI
# Warmup Iteration 1: 170,613 ops/us
# Warmup Iteration 2: 173,507 ops/us
# Warmup Iteration 3: 172,855 ops/us
Iteration 1: 173,949 ops/us
Iteration 2: 174,088 ops/us
Iteration 3: 174,164 ops/us
Result : 174,067 ±(99.9%) 1,986 ops/us
Statistics: (min, avg, max) = (173,949, 174,067, 174,164), stdev = 0,109
Confidence interval (99.9%): [172,081, 176,054]
# Run progress: 75,00% complete, ETA 00:00:06
# VM invoker: c:\Program Files\Java\jdk1.7.0_51\jre\bin\java.exe
# VM options: <none>
# Fork: 1 of 1
# Warmup: 3 iterations, 1 s each
# Measurement: 3 iterations, 1 s each
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: net.eckenfels.tests.jmh.SingletonAccess.measureVolatileNI
# Warmup Iteration 1: 168,592 ops/us
# Warmup Iteration 2: 171,529 ops/us
# Warmup Iteration 3: 173,441 ops/us
Iteration 1: 173,256 ops/us
Iteration 2: 173,492 ops/us
Iteration 3: 172,936 ops/us
Result : 173,228 ±(99.9%) 5,090 ops/us
Statistics: (min, avg, max) = (172,936, 173,228, 173,492), stdev = 0,279
Confidence interval (99.9%): [168,138, 178,319]
Benchmark Mode Samples Mean Mean error Units
n.e.t.j.SingletonAccess.measureVolatile thrpt 3 172,825 14,753 ops/us
n.e.t.j.SingletonAccess.measureVolatileE thrpt 3 12,557 1,744 ops/us
n.e.t.j.SingletonAccess.measureVolatileI thrpt 3 174,067 1,986 ops/us
n.e.t.j.SingletonAccess.measureVolatileNI thrpt 3 173,228 5,090 ops/us
package net.eckenfels.tests.jmh;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.openjdk.jmh.annotations.CompilerControl;
import org.openjdk.jmh.annotations.CompilerControl.Mode;
import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.logic.BlackHole;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@State(Scope.Benchmark)
public class SingletonAccess
{
volatile Object ref1 = new Object();
Object ref2 = new Object();
AtomicReference<Object> ref3 = new AtomicReference<Object>(new Object());
Object ref4 = new Object();
@GenerateMicroBenchmark
@CompilerControl(Mode.INLINE)
public void measureVolatileI(BlackHole bh) {
Object o = ref1;
bh.consume(o);
}
@GenerateMicroBenchmark
@CompilerControl(Mode.DONT_INLINE)
public void measureVolatileNI(BlackHole bh) {
Object o = ref1;
bh.consume(o);
}
@GenerateMicroBenchmark
@CompilerControl(Mode.EXCLUDE)
public void measureVolatileE(BlackHole bh) {
Object o = ref1;
bh.consume(o);
}
@GenerateMicroBenchmark
public void measureVolatile(BlackHole bh) {
Object o = ref1;
bh.consume(o);
}
@GenerateMicroBenchmark
@CompilerControl(Mode.DONT_INLINE)
public void measureFieldNI(BlackHole bh) {
Object o = ref2;
bh.consume(o);
}
@GenerateMicroBenchmark
@CompilerControl(Mode.INLINE)
public void measureFieldI(BlackHole bh) {
Object o = ref2;
bh.consume(o);
}
@GenerateMicroBenchmark
@CompilerControl(Mode.INLINE)
public void measureAtomicI(BlackHole bh) {
Object o = ref3.get();
bh.consume(o);
}
@GenerateMicroBenchmark
@CompilerControl(Mode.DONT_INLINE)
public void measureAtomicNI(BlackHole bh) {
Object o = ref3.get();
bh.consume(o);
}
@GenerateMicroBenchmark
@CompilerControl(Mode.INLINE)
public void measureSyncI(BlackHole bh) {
Object o;
synchronized (this)
{
o = ref4;
}
bh.consume(o);
}
@GenerateMicroBenchmark
@CompilerControl(Mode.DONT_INLINE)
public void measureSyncNI(BlackHole bh) {
Object o;
synchronized (this)
{
o = ref4;
}
bh.consume(o);
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(".*" + SingletonAccess.class.getSimpleName() + ".*")
.warmupIterations(5)
.measurementIterations(5)
.forks(1)
.build();
new Runner(opt).run();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.