Skip to content

Instantly share code, notes, and snippets.

@leventov
Created September 8, 2015 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leventov/fd596b9ff92141105bf1 to your computer and use it in GitHub Desktop.
Save leventov/fd596b9ff92141105bf1 to your computer and use it in GitHub Desktop.
# JMH 1.10.5 (released 11 days ago)
# VM version: JDK 1.8.0_60, VM 25.60-b23
# VM invoker: C:\Program Files\Java\jdk1.8\jre\bin\java.exe
# VM options: -Didea.launcher.port=7532 -Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA UE 14\bin -Dfile.encoding=windows-1251
# Warmup: 3 iterations, 1 s each
# Measurement: 5 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: tests.SmoothieMapBenchmark.entrySetForeachHashMap
# Run progress: 0,00% complete, ETA 00:02:24
# Fork: 1 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
3,713 ms/op
# Warmup Iteration 2: 3,602 ms/op
# Warmup Iteration 3: 3,575 ms/op
Iteration 1: 3,570 ms/op
Iteration 2: 3,577 ms/op
Iteration 3: 3,578 ms/op
Iteration 4: 3,657 ms/op
Iteration 5: 3,573 ms/op
# Run progress: 5,56% complete, ETA 00:02:46
# Fork: 2 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
3,916 ms/op
# Warmup Iteration 2: 3,740 ms/op
# Warmup Iteration 3: 3,737 ms/op
Iteration 1: 3,713 ms/op
Iteration 2: 3,719 ms/op
Iteration 3: 3,706 ms/op
Iteration 4: 3,708 ms/op
Iteration 5: 3,713 ms/op
# Run progress: 11,11% complete, ETA 00:02:32
# Fork: 3 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
3,549 ms/op
# Warmup Iteration 2: 3,654 ms/op
# Warmup Iteration 3: 3,774 ms/op
Iteration 1: 3,588 ms/op
Iteration 2: 3,550 ms/op
Iteration 3: 3,553 ms/op
Iteration 4: 3,550 ms/op
Iteration 5: 3,547 ms/op
Result "entrySetForeachHashMap":
3,620 ?(99.9%) 0,077 ms/op [Average]
(min, avg, max) = (3,547, 3,620, 3,719), stdev = 0,072
CI (99.9%): [3,543, 3,697] (assumes normal distribution)
# JMH 1.10.5 (released 11 days ago)
# VM version: JDK 1.8.0_60, VM 25.60-b23
# VM invoker: C:\Program Files\Java\jdk1.8\jre\bin\java.exe
# VM options: -Didea.launcher.port=7532 -Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA UE 14\bin -Dfile.encoding=windows-1251
# Warmup: 3 iterations, 1 s each
# Measurement: 5 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: tests.SmoothieMapBenchmark.entrySetForeachSmoothieMap
# Run progress: 16,67% complete, ETA 00:02:21
# Fork: 1 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2,426 ms/op
# Warmup Iteration 2: 2,338 ms/op
# Warmup Iteration 3: 2,351 ms/op
Iteration 1: 2,358 ms/op
Iteration 2: 2,325 ms/op
Iteration 3: 2,343 ms/op
Iteration 4: 2,331 ms/op
Iteration 5: 2,421 ms/op
# Run progress: 22,22% complete, ETA 00:02:11
# Fork: 2 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2,275 ms/op
# Warmup Iteration 2: 2,297 ms/op
# Warmup Iteration 3: 2,233 ms/op
Iteration 1: 2,242 ms/op
Iteration 2: 2,333 ms/op
Iteration 3: 2,235 ms/op
Iteration 4: 2,240 ms/op
Iteration 5: 2,232 ms/op
# Run progress: 27,78% complete, ETA 00:02:01
# Fork: 3 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2,235 ms/op
# Warmup Iteration 2: 2,208 ms/op
# Warmup Iteration 3: 2,223 ms/op
Iteration 1: 2,207 ms/op
Iteration 2: 2,222 ms/op
Iteration 3: 2,204 ms/op
Iteration 4: 2,204 ms/op
Iteration 5: 2,277 ms/op
Result "entrySetForeachSmoothieMap":
2,278 ?(99.9%) 0,073 ms/op [Average]
(min, avg, max) = (2,204, 2,278, 2,421), stdev = 0,068
CI (99.9%): [2,206, 2,351] (assumes normal distribution)
# JMH 1.10.5 (released 11 days ago)
# VM version: JDK 1.8.0_60, VM 25.60-b23
# VM invoker: C:\Program Files\Java\jdk1.8\jre\bin\java.exe
# VM options: -Didea.launcher.port=7532 -Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA UE 14\bin -Dfile.encoding=windows-1251
# Warmup: 3 iterations, 1 s each
# Measurement: 5 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: tests.SmoothieMapBenchmark.foreachHashMap
# Run progress: 33,33% complete, ETA 00:01:52
# Fork: 1 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
3,867 ms/op
# Warmup Iteration 2: 3,647 ms/op
# Warmup Iteration 3: 3,656 ms/op
Iteration 1: 3,858 ms/op
Iteration 2: 3,658 ms/op
Iteration 3: 3,658 ms/op
Iteration 4: 3,648 ms/op
Iteration 5: 3,637 ms/op
# Run progress: 38,89% complete, ETA 00:01:42
# Fork: 2 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
3,590 ms/op
# Warmup Iteration 2: 3,510 ms/op
# Warmup Iteration 3: 3,513 ms/op
Iteration 1: 3,512 ms/op
Iteration 2: 3,524 ms/op
Iteration 3: 3,513 ms/op
Iteration 4: 3,988 ms/op
Iteration 5: 3,508 ms/op
# Run progress: 44,44% complete, ETA 00:01:33
# Fork: 3 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
3,642 ms/op
# Warmup Iteration 2: 3,643 ms/op
# Warmup Iteration 3: 3,577 ms/op
Iteration 1: 3,602 ms/op
Iteration 2: 3,573 ms/op
Iteration 3: 3,585 ms/op
Iteration 4: 3,573 ms/op
Iteration 5: 3,583 ms/op
Result "foreachHashMap":
3,628 ?(99.9%) 0,142 ms/op [Average]
(min, avg, max) = (3,508, 3,628, 3,988), stdev = 0,133
CI (99.9%): [3,486, 3,770] (assumes normal distribution)
# JMH 1.10.5 (released 11 days ago)
# VM version: JDK 1.8.0_60, VM 25.60-b23
# VM invoker: C:\Program Files\Java\jdk1.8\jre\bin\java.exe
# VM options: -Didea.launcher.port=7532 -Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA UE 14\bin -Dfile.encoding=windows-1251
# Warmup: 3 iterations, 1 s each
# Measurement: 5 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: tests.SmoothieMapBenchmark.foreachSmoothieMap
# Run progress: 50,00% complete, ETA 00:01:23
# Fork: 1 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
1,926 ms/op
# Warmup Iteration 2: 1,862 ms/op
# Warmup Iteration 3: 1,861 ms/op
Iteration 1: 1,864 ms/op
Iteration 2: 1,863 ms/op
Iteration 3: 1,859 ms/op
Iteration 4: 1,857 ms/op
Iteration 5: 1,861 ms/op
# Run progress: 55,56% complete, ETA 00:01:14
# Fork: 2 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
1,931 ms/op
# Warmup Iteration 2: 1,847 ms/op
# Warmup Iteration 3: 1,847 ms/op
Iteration 1: 1,877 ms/op
Iteration 2: 1,846 ms/op
Iteration 3: 1,853 ms/op
Iteration 4: 1,854 ms/op
Iteration 5: 1,847 ms/op
# Run progress: 61,11% complete, ETA 00:01:05
# Fork: 3 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
1,920 ms/op
# Warmup Iteration 2: 1,880 ms/op
# Warmup Iteration 3: 1,894 ms/op
Iteration 1: 1,907 ms/op
Iteration 2: 1,889 ms/op
Iteration 3: 1,889 ms/op
Iteration 4: 1,884 ms/op
Iteration 5: 1,915 ms/op
Result "foreachSmoothieMap":
1,871 ?(99.9%) 0,023 ms/op [Average]
(min, avg, max) = (1,846, 1,871, 1,915), stdev = 0,021
CI (99.9%): [1,848, 1,894] (assumes normal distribution)
# JMH 1.10.5 (released 11 days ago)
# VM version: JDK 1.8.0_60, VM 25.60-b23
# VM invoker: C:\Program Files\Java\jdk1.8\jre\bin\java.exe
# VM options: -Didea.launcher.port=7532 -Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA UE 14\bin -Dfile.encoding=windows-1251
# Warmup: 3 iterations, 1 s each
# Measurement: 5 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: tests.SmoothieMapBenchmark.iteratorHashMap
# Run progress: 66,67% complete, ETA 00:00:55
# Fork: 1 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
4,363 ms/op
# Warmup Iteration 2: 4,324 ms/op
# Warmup Iteration 3: 4,357 ms/op
Iteration 1: 4,326 ms/op
Iteration 2: 4,325 ms/op
Iteration 3: 4,326 ms/op
Iteration 4: 4,317 ms/op
Iteration 5: 4,326 ms/op
# Run progress: 72,22% complete, ETA 00:00:46
# Fork: 2 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
4,751 ms/op
# Warmup Iteration 2: 4,319 ms/op
# Warmup Iteration 3: 4,312 ms/op
Iteration 1: 4,306 ms/op
Iteration 2: 4,298 ms/op
Iteration 3: 4,294 ms/op
Iteration 4: 4,288 ms/op
Iteration 5: 4,296 ms/op
# Run progress: 77,78% complete, ETA 00:00:37
# Fork: 3 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
4,578 ms/op
# Warmup Iteration 2: 4,245 ms/op
# Warmup Iteration 3: 4,205 ms/op
Iteration 1: 4,248 ms/op
Iteration 2: 4,212 ms/op
Iteration 3: 4,207 ms/op
Iteration 4: 4,195 ms/op
Iteration 5: 4,219 ms/op
Result "iteratorHashMap":
4,279 ?(99.9%) 0,052 ms/op [Average]
(min, avg, max) = (4,195, 4,279, 4,326), stdev = 0,049
CI (99.9%): [4,227, 4,331] (assumes normal distribution)
# JMH 1.10.5 (released 11 days ago)
# VM version: JDK 1.8.0_60, VM 25.60-b23
# VM invoker: C:\Program Files\Java\jdk1.8\jre\bin\java.exe
# VM options: -Didea.launcher.port=7532 -Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA UE 14\bin -Dfile.encoding=windows-1251
# Warmup: 3 iterations, 1 s each
# Measurement: 5 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: tests.SmoothieMapBenchmark.iteratorSmoothieMap
# Run progress: 83,33% complete, ETA 00:00:27
# Fork: 1 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2,239 ms/op
# Warmup Iteration 2: 2,205 ms/op
# Warmup Iteration 3: 2,206 ms/op
Iteration 1: 2,211 ms/op
Iteration 2: 2,204 ms/op
Iteration 3: 2,207 ms/op
Iteration 4: 2,205 ms/op
Iteration 5: 2,207 ms/op
# Run progress: 88,89% complete, ETA 00:00:18
# Fork: 2 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2,349 ms/op
# Warmup Iteration 2: 2,221 ms/op
# Warmup Iteration 3: 2,212 ms/op
Iteration 1: 2,215 ms/op
Iteration 2: 2,221 ms/op
Iteration 3: 2,208 ms/op
Iteration 4: 2,219 ms/op
Iteration 5: 2,222 ms/op
# Run progress: 94,44% complete, ETA 00:00:09
# Fork: 3 of 3
# Warmup Iteration 1: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2,370 ms/op
# Warmup Iteration 2: 2,257 ms/op
# Warmup Iteration 3: 2,245 ms/op
Iteration 1: 2,256 ms/op
Iteration 2: 2,248 ms/op
Iteration 3: 2,263 ms/op
Iteration 4: 2,242 ms/op
Iteration 5: 2,245 ms/op
Result "iteratorSmoothieMap":
2,225 ?(99.9%) 0,022 ms/op [Average]
(min, avg, max) = (2,204, 2,225, 2,263), stdev = 0,020
CI (99.9%): [2,203, 2,247] (assumes normal distribution)
# Run complete. Total time: 00:02:47
Benchmark Mode Cnt Score Error Units
SmoothieMapBenchmark.entrySetForeachHashMap avgt 15 3,620 ? 0,077 ms/op
SmoothieMapBenchmark.entrySetForeachSmoothieMap avgt 15 2,278 ? 0,073 ms/op
SmoothieMapBenchmark.foreachHashMap avgt 15 3,628 ? 0,142 ms/op
SmoothieMapBenchmark.foreachSmoothieMap avgt 15 1,871 ? 0,023 ms/op
SmoothieMapBenchmark.iteratorHashMap avgt 15 4,279 ? 0,052 ms/op
SmoothieMapBenchmark.iteratorSmoothieMap avgt 15 2,225 ? 0,022 ms/op
package tests;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
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;
import net.openhft.smoothie.SmoothieMap;
@BenchmarkMode(Mode.AverageTime)
@Fork(3)
@State(Scope.Benchmark)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
public class SmoothieMapBenchmark {
private Map<Integer, String> smoothieMap = new SmoothieMap<>();
private Map<Integer, String> hashMap = new HashMap<>();
@Setup()
public void setup() {
new Random(228L).ints().distinct().limit(100000).forEach(i -> {
smoothieMap.put(Integer.valueOf(i), String.valueOf(i));
hashMap.put(Integer.valueOf(i), String.valueOf(i));
});
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(".*" + SmoothieMapBenchmark.class.getSimpleName() + ".*")
// .addProfiler(LinuxPerfNormProfiler.class)
.build();
new Runner(opt).run();
}
@Benchmark
public void iteratorHashMap() {
for (Entry<Integer, String> entry : hashMap.entrySet()) {
action(entry.getKey(), entry.getValue());
}
}
@Benchmark
public void entrySetForeachHashMap() {
hashMap.entrySet().forEach(e -> {
action(e.getKey(), e.getValue());
});
}
@Benchmark
public void entrySetForeachSmoothieMap() {
smoothieMap.entrySet().forEach(e -> {
action(e.getKey(), e.getValue());
});
}
@Benchmark
public void iteratorSmoothieMap() {
for (Entry<Integer, String> entry : smoothieMap.entrySet()) {
action(entry.getKey(), entry.getValue());
}
}
@Benchmark
public void foreachSmoothieMap() {
smoothieMap.forEach((k, v) -> {
action(k, v);
});
}
@Benchmark
public void foreachHashMap() {
hashMap.forEach((k, v) -> {
action(k, v);
});
}
private static void action(int k, String v) {
if (k == 0 && v == null)
throw new AssertionError();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment