Skip to content

Instantly share code, notes, and snippets.

@leogomes
Last active May 3, 2017 14:51
Show Gist options
  • Save leogomes/9dabca2f6e0b9a8707208e934c70bb17 to your computer and use it in GitHub Desktop.
Save leogomes/9dabca2f6e0b9a8707208e934c70bb17 to your computer and use it in GitHub Desktop.
# JMH 1.18 (released 51 days ago)
# VM version: JDK 1.8.0_131, VM 25.131-b11
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/bin/java
# VM options: -Dfile.encoding=UTF-8
# Warmup: 5 iterations, 5 s each
# Measurement: 5 iterations, 5 s each
# Timeout: 10 min per iteration
# Threads: 32 threads, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: fr.rivieradev.jmh.MapConcurrency.concurrentMap
# Run progress: 0.00% complete, ETA 00:01:40
# Fork: 1 of 1
# Warmup Iteration 1: 2110.560 ops/ms
# Warmup Iteration 2: 2094.425 ops/ms
# Warmup Iteration 3: 2023.174 ops/ms
# Warmup Iteration 4: 1868.173 ops/ms
# Warmup Iteration 5: 1931.164 ops/ms
Iteration 1: 2158.944 ops/ms
·stack: <delayed till summary>
Iteration 2: 2118.430 ops/ms
·stack: <delayed till summary>
Iteration 3: 2230.242 ops/ms
·stack: <delayed till summary>
Iteration 4: 2241.634 ops/ms
·stack: <delayed till summary>
Iteration 5: 2116.250 ops/ms
·stack: <delayed till summary>
Result "fr.rivieradev.jmh.MapConcurrency.concurrentMap":
2173.100 ±(99.9%) 230.904 ops/ms [Average]
(min, avg, max) = (2116.250, 2173.100, 2241.634), stdev = 59.965
CI (99.9%): [1942.196, 2404.004] (assumes normal distribution)
Secondary result "fr.rivieradev.jmh.MapConcurrency.concurrentMap:·stack":
Stack profiler:
....[Thread state distributions]....................................................................
73.6% BLOCKED
25.5% RUNNABLE
0.9% WAITING
....[Thread state: BLOCKED].........................................................................
73.6% 100.0% java.util.concurrent.ConcurrentHashMap.putVal
....[Thread state: RUNNABLE]........................................................................
21.2% 83.0% java.util.concurrent.ConcurrentHashMap.putVal
4.3% 16.9% java.util.concurrent.ConcurrentHashMap.put
0.0% 0.1% fr.rivieradev.jmh.generated.MapConcurrency_concurrentMap_jmhTest.concurrentMap_thrpt_jmhStub
0.0% 0.0% java.lang.Thread.isInterrupted
0.0% 0.0% sun.misc.Unsafe.unpark
0.0% 0.0% org.openjdk.jmh.runner.InfraControlL2.announceWarmdownReady
....[Thread state: WAITING].........................................................................
0.9% 100.0% sun.misc.Unsafe.park
# JMH 1.18 (released 51 days ago)
# VM version: JDK 1.8.0_131, VM 25.131-b11
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/bin/java
# VM options: -Dfile.encoding=UTF-8
# Warmup: 5 iterations, 5 s each
# Measurement: 5 iterations, 5 s each
# Timeout: 10 min per iteration
# Threads: 32 threads, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: fr.rivieradev.jmh.MapConcurrency.hashtable
# Run progress: 50.00% complete, ETA 00:00:52
# Fork: 1 of 1
# Warmup Iteration 1: 1553.078 ops/ms
# Warmup Iteration 2: 1629.132 ops/ms
# Warmup Iteration 3: 1556.156 ops/ms
# Warmup Iteration 4: 1469.335 ops/ms
# Warmup Iteration 5: 1601.408 ops/ms
Iteration 1: 1459.813 ops/ms
·stack: <delayed till summary>
Iteration 2: 1564.596 ops/ms
·stack: <delayed till summary>
Iteration 3: 1510.494 ops/ms
·stack: <delayed till summary>
Iteration 4: 1564.305 ops/ms
·stack: <delayed till summary>
Iteration 5: 1415.077 ops/ms
·stack: <delayed till summary>
Result "fr.rivieradev.jmh.MapConcurrency.hashtable":
1502.857 ±(99.9%) 252.532 ops/ms [Average]
(min, avg, max) = (1415.077, 1502.857, 1564.596), stdev = 65.582
CI (99.9%): [1250.325, 1755.389] (assumes normal distribution)
Secondary result "fr.rivieradev.jmh.MapConcurrency.hashtable:·stack":
Stack profiler:
....[Thread state distributions]....................................................................
93.1% BLOCKED
6.7% RUNNABLE
0.2% WAITING
....[Thread state: BLOCKED].........................................................................
93.1% 100.0% java.util.Hashtable.put
....[Thread state: RUNNABLE]........................................................................
5.9% 88.5% java.util.Hashtable.put
0.8% 11.3% fr.rivieradev.jmh.MapConcurrency.hashtable
0.0% 0.1% fr.rivieradev.jmh.generated.MapConcurrency_hashtable_jmhTest.hashtable_thrpt_jmhStub
0.0% 0.0% org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call
....[Thread state: WAITING].........................................................................
0.2% 100.0% sun.misc.Unsafe.park
# Run complete. Total time: 00:01:42
Benchmark Mode Cnt Score Error Units
MapConcurrency.concurrentMap thrpt 5 2173.100 ± 230.904 ops/ms
MapConcurrency.concurrentMap:·stack thrpt NaN ---
MapConcurrency.hashtable thrpt 5 1502.857 ± 252.532 ops/ms
MapConcurrency.hashtable:·stack thrpt NaN ---
# JMH 1.18 (released 51 days ago)
# VM version: JDK 1.8.0_131, VM 25.131-b11
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/bin/java
# VM options: -Dfile.encoding=UTF-8
# Warmup: 5 iterations, 5 s each
# Measurement: 5 iterations, 5 s each
# Timeout: 10 min per iteration
# Threads: 8 threads, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: fr.rivieradev.jmh.MapConcurrency.concurrentMap
# Run progress: 0.00% complete, ETA 00:01:40
# Fork: 1 of 1
# Warmup Iteration 1: 2109.761 ops/ms
# Warmup Iteration 2: 2103.362 ops/ms
# Warmup Iteration 3: 2079.126 ops/ms
# Warmup Iteration 4: 2047.054 ops/ms
# Warmup Iteration 5: 2078.678 ops/ms
Iteration 1: 2327.722 ops/ms
·stack: <delayed till summary>
Iteration 2: 2330.567 ops/ms
·stack: <delayed till summary>
Iteration 3: 2335.295 ops/ms
·stack: <delayed till summary>
Iteration 4: 2337.179 ops/ms
·stack: <delayed till summary>
Iteration 5: 2322.277 ops/ms
·stack: <delayed till summary>
Result "fr.rivieradev.jmh.MapConcurrency.concurrentMap":
2330.608 ±(99.9%) 23.015 ops/ms [Average]
(min, avg, max) = (2322.277, 2330.608, 2337.179), stdev = 5.977
CI (99.9%): [2307.593, 2353.623] (assumes normal distribution)
Secondary result "fr.rivieradev.jmh.MapConcurrency.concurrentMap:·stack":
Stack profiler:
....[Thread state distributions]....................................................................
80.1% RUNNABLE
19.6% BLOCKED
0.2% WAITING
....[Thread state: RUNNABLE]........................................................................
64.1% 79.9% java.util.concurrent.ConcurrentHashMap.putVal
16.0% 19.9% java.util.concurrent.ConcurrentHashMap.put
0.1% 0.1% fr.rivieradev.jmh.generated.MapConcurrency_concurrentMap_jmhTest.concurrentMap_thrpt_jmhStub
0.0% 0.0% org.openjdk.jmh.runner.InfraControl.announceWarmdownReady
0.0% 0.0% sun.misc.Unsafe.park
0.0% 0.0% java.util.concurrent.CountDownLatch$Sync.tryReleaseShared
0.0% 0.0% sun.misc.Unsafe.unpark
0.0% 0.0% sun.misc.Unsafe.getIntVolatile
0.0% 0.0% java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued
....[Thread state: BLOCKED].........................................................................
19.6% 100.0% java.util.concurrent.ConcurrentHashMap.putVal
....[Thread state: WAITING].........................................................................
0.2% 100.0% sun.misc.Unsafe.park
# JMH 1.18 (released 51 days ago)
# VM version: JDK 1.8.0_131, VM 25.131-b11
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/bin/java
# VM options: -Dfile.encoding=UTF-8
# Warmup: 5 iterations, 5 s each
# Measurement: 5 iterations, 5 s each
# Timeout: 10 min per iteration
# Threads: 8 threads, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: fr.rivieradev.jmh.MapConcurrency.hashtable
# Run progress: 50.00% complete, ETA 00:00:50
# Fork: 1 of 1
# Warmup Iteration 1: 1482.001 ops/ms
# Warmup Iteration 2: 1471.862 ops/ms
# Warmup Iteration 3: 1658.078 ops/ms
# Warmup Iteration 4: 1739.174 ops/ms
# Warmup Iteration 5: 1712.471 ops/ms
Iteration 1: 1625.341 ops/ms
·stack: <delayed till summary>
Iteration 2: 1665.187 ops/ms
·stack: <delayed till summary>
Iteration 3: 1681.749 ops/ms
·stack: <delayed till summary>
Iteration 4: 1620.506 ops/ms
·stack: <delayed till summary>
Iteration 5: 1535.764 ops/ms
·stack: <delayed till summary>
Result "fr.rivieradev.jmh.MapConcurrency.hashtable":
1625.709 ±(99.9%) 217.963 ops/ms [Average]
(min, avg, max) = (1535.764, 1625.709, 1681.749), stdev = 56.604
CI (99.9%): [1407.746, 1843.673] (assumes normal distribution)
Secondary result "fr.rivieradev.jmh.MapConcurrency.hashtable:·stack":
Stack profiler:
....[Thread state distributions]....................................................................
72.5% BLOCKED
27.3% RUNNABLE
0.2% WAITING
....[Thread state: BLOCKED].........................................................................
72.5% 100.0% java.util.Hashtable.put
....[Thread state: RUNNABLE]........................................................................
23.3% 85.1% java.util.Hashtable.put
4.0% 14.7% fr.rivieradev.jmh.MapConcurrency.hashtable
0.0% 0.1% fr.rivieradev.jmh.generated.MapConcurrency_hashtable_jmhTest.hashtable_thrpt_jmhStub
0.0% 0.0% java.lang.Thread.currentThread
0.0% 0.0% org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call
....[Thread state: WAITING].........................................................................
0.2% 100.0% sun.misc.Unsafe.park
# Run complete. Total time: 00:01:41
Benchmark Mode Cnt Score Error Units
MapConcurrency.concurrentMap thrpt 5 2330.608 ± 23.015 ops/ms
MapConcurrency.concurrentMap:·stack thrpt NaN ---
MapConcurrency.hashtable thrpt 5 1625.709 ± 217.963 ops/ms
MapConcurrency.hashtable:·stack thrpt NaN ---
/**
* TBD
*/
@Warmup(iterations = 5, time = 5, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 5, timeUnit = TimeUnit.SECONDS)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(1)
public class MapConcurrency {
@Benchmark
@Threads(8)
public void hashtable(BenchmarkState bench, ThreadState thread) {
for (String s : thread.ids) {
bench.hashtable.put(s, s);
}
}
@Benchmark
@Threads(8)
public void concurrentMap(BenchmarkState bench, ThreadState thread) {
for (String s : thread.ids) {
bench.map.put(s, s);
}
}
@State(Scope.Benchmark)
public static class BenchmarkState {
Hashtable<String, String> hashtable = new Hashtable<>();
ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
}
@State(Scope.Thread)
public static class ThreadState {
private static final int COUNT = 10;
private List<String> ids;
@Setup
public void setup() {
ids = new ArrayList<>();
for (int i = 0; i < COUNT; i++) {
String e = "ID" + i;
ids.add(e);
}
Collections.shuffle(ids);
}
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(MapConcurrency.class.getSimpleName())
.addProfiler(StackProfiler.class)
.build();
new Runner(opt).run();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment