# Run complete. Total time: 00:02:42
REMEMBER: The numbers below are just data. To gain reusable insights, you need to follow up on
why the numbers are the way they are. Use profilers (see -prof, -lprof), design factorial
experiments, perform baseline and negative tests that provide experimental control, make sure
the benchmarking environment is safe on JVM/OS/HW level, ask for reviews from the domain experts.
Do not assume the numbers tell you what you want them to tell.
// 测试结果对比
Benchmark Mode Cnt Score Error Units
JmhHello.stringAdd avgt 5 267.393 ± 189.907 ms/op
JmhHello.stringBuilderAppend avgt 5 8.847 ± 4.844 ms/op
# JMH version: 1.35 # VM version: JDK 17, Java HotSpot(TM) 64-Bit Server VM, 17+35-LTS-2724 # VM invoker: D:\devPrograms\jdk\jdk-17_windows-x64_bin\jdk-17\bin\java.exe # VM options: -javaagent:D:\devPrograms\JetBrains\ideaIU-2022.1.3.win\lib\idea_rt.jar=50503:D:\devPrograms\JetBrains\ideaIU-2022.1.3.win\bin -Dfile.encoding=UTF-8 # Blackhole mode: compiler (auto-detected, use -Djmh.blackhole.autoDetect=false to disable) # Warmup: 3 iterations, 10 s each # Measurement: 5 iterations, 10 s each # Timeout: 10 min per iteration # Threads: 1 thread, will synchronize iterations # Benchmark mode: Average time, time/op # Benchmark: jmh.JmhHello.stringAdd
Result "jmh.JmhHello.stringAdd": 173.348 ±(99.9%) 106.138 ms/op [Average] (min, avg, max) = (131.892, 173.348, 209.361), stdev = 27.564 CI (99.9%): [67.210, 279.486] (assumes normal distribution)
# JMH version: 1.35 # VM version: JDK 17, Java HotSpot(TM) 64-Bit Server VM, 17+35-LTS-2724 # VM invoker: D:\devPrograms\jdk\jdk-17_windows-x64_bin\jdk-17\bin\java.exe # VM options: -javaagent:D:\devPrograms\JetBrains\ideaIU-2022.1.3.win\lib\idea_rt.jar=50503:D:\devPrograms\JetBrains\ideaIU-2022.1.3.win\bin -Dfile.encoding=UTF-8 # Blackhole mode: compiler (auto-detected, use -Djmh.blackhole.autoDetect=false to disable) # Warmup: 3 iterations, 10 s each # Measurement: 5 iterations, 10 s each # Timeout: 10 min per iteration # Threads: 1 thread, will synchronize iterations # Benchmark mode: Average time, time/op # Benchmark: jmh.JmhHello.stringBuilderAppend
Result "jmh.JmhHello.stringBuilderAppend": 6.884 ±(99.9%) 3.508 ms/op [Average] (min, avg, max) = (5.732, 6.884, 8.269), stdev = 0.911 CI (99.9%): [3.376, 10.392] (assumes normal distribution)
# Run complete. Total time: 00:02:42
REMEMBER: The numbers below are just data. To gain reusable insights, you need to follow up on why the numbers are the way they are. Use profilers (see -prof, -lprof), design factorial experiments, perform baseline and negative tests that provide experimental control, make sure the benchmarking environment is safe onJVM/OS/HWlevel, askforreviewsfromthedomainexperts. Do not assume the numbers tell you what you want them to tell.
NOTE: Current JVM experimentally supports Compiler Blackholes, and they are in use. Please exercise extra caution when trusting the results, look intothe generated code to check the benchmark still works, and factor ina small probability ofnew VM bugs. Additionally, while comparisons between different JVMs are already problematic, the performance difference caused by different Blackhole modes can be very significant. Please make sure you use the consistent Blackhole mode for comparisons.