Files
java-core-examples/locks/output/04-increment-benchmark-sweep.txt
asmhatre 32b8067ecf locks: synchronized vs ReentrantLock vs StampedLock companion code
JMH throughput sweep (1-64 threads), 9:1 read-heavy @Group benchmark,
tryLock(timeout) deadlock-avoidance demo, and a JDK21-vs-JDK25 JEP 491
virtual-thread-pinning comparison. Also promotes LICENSE to repo root
now that a second module exists.
2026-09-30 06:04:50 +00:00

53 lines
3.1 KiB
Plaintext

$ java -jar target/benchmarks.jar IncrementBenchmark -t <N> -rf text
(one JVM invocation per thread count; -t sets the JMH thread count for that run)
=== threads=1 ===
Benchmark Mode Cnt Score Error Units
IncrementBenchmark.reentrantLockFair thrpt 5 52315.361 ± 7000.813 ops/ms
IncrementBenchmark.reentrantLockUnfair thrpt 5 52462.260 ± 3295.127 ops/ms
IncrementBenchmark.stampedLockWrite thrpt 5 51466.587 ± 12682.048 ops/ms
IncrementBenchmark.synchronized_ thrpt 5 43053.756 ± 4276.407 ops/ms
=== threads=2 ===
Benchmark Mode Cnt Score Error Units
IncrementBenchmark.reentrantLockFair thrpt 5 984.984 ± 1624.886 ops/ms
IncrementBenchmark.reentrantLockUnfair thrpt 5 13316.608 ± 4428.282 ops/ms
IncrementBenchmark.stampedLockWrite thrpt 5 15243.885 ± 3805.083 ops/ms
IncrementBenchmark.synchronized_ thrpt 5 10285.533 ± 6953.617 ops/ms
=== threads=4 ===
Benchmark Mode Cnt Score Error Units
IncrementBenchmark.reentrantLockFair thrpt 5 149.465 ± 598.480 ops/ms
IncrementBenchmark.reentrantLockUnfair thrpt 5 43978.589 ± 8289.565 ops/ms
IncrementBenchmark.stampedLockWrite thrpt 5 50067.586 ± 4023.378 ops/ms
IncrementBenchmark.synchronized_ thrpt 5 7373.456 ± 5254.126 ops/ms
=== threads=8 ===
Benchmark Mode Cnt Score Error Units
IncrementBenchmark.reentrantLockFair thrpt 5 77.622 ± 9.397 ops/ms
IncrementBenchmark.reentrantLockUnfair thrpt 5 50180.739 ± 8707.699 ops/ms
IncrementBenchmark.stampedLockWrite thrpt 5 54031.902 ± 4571.353 ops/ms
IncrementBenchmark.synchronized_ thrpt 5 7431.158 ± 2055.967 ops/ms
=== threads=16 ===
Benchmark Mode Cnt Score Error Units
IncrementBenchmark.reentrantLockFair thrpt 5 81.785 ± 23.399 ops/ms
IncrementBenchmark.reentrantLockUnfair thrpt 5 45460.231 ± 5190.390 ops/ms
IncrementBenchmark.stampedLockWrite thrpt 5 46998.078 ± 3362.893 ops/ms
IncrementBenchmark.synchronized_ thrpt 5 8185.253 ± 3341.605 ops/ms
=== threads=32 ===
Benchmark Mode Cnt Score Error Units
IncrementBenchmark.reentrantLockFair thrpt 5 71.593 ± 24.857 ops/ms
IncrementBenchmark.reentrantLockUnfair thrpt 5 45325.559 ± 1160.775 ops/ms
IncrementBenchmark.stampedLockWrite thrpt 5 46630.727 ± 4303.326 ops/ms
IncrementBenchmark.synchronized_ thrpt 5 9378.353 ± 7605.473 ops/ms
=== threads=64 ===
Benchmark Mode Cnt Score Error Units
IncrementBenchmark.reentrantLockFair thrpt 5 69.470 ± 5.015 ops/ms
IncrementBenchmark.reentrantLockUnfair thrpt 5 44724.521 ± 5166.580 ops/ms
IncrementBenchmark.stampedLockWrite thrpt 5 46973.404 ± 3639.073 ops/ms
IncrementBenchmark.synchronized_ thrpt 5 12510.129 ± 3496.906 ops/ms