commons-lang
commons-lang copied to clipboard
[LANG-1601] Refine performance of fraction.pow
[INFO] --- exec-maven-plugin:1.6.0:exec (benchmark) @ commons-lang3 ---
# JMH version: 1.21
# VM version: JDK 1.8.0_265, OpenJDK 64-Bit Server VM, 25.265-b01
# VM invoker: C:\jdk8u265-b01\jre\bin\java.exe
# VM options: -server -Xms2048M -Xms2048M
# Warmup: 5 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: org.apache.commons.lang3.math.FractionPowPerformanceTest.testNew
# Run progress: 0.00% complete, ETA 00:03:20
# Fork: 1 of 1
# Warmup Iteration 1: 132128.103 ns/op
# Warmup Iteration 2: 137977.136 ns/op
# Warmup Iteration 3: 126261.936 ns/op
# Warmup Iteration 4: 126523.312 ns/op
# Warmup Iteration 5: 128990.556 ns/op
Iteration 1: 124878.319 ns/op
Iteration 2: 124090.416 ns/op
Iteration 3: 125770.206 ns/op
Iteration 4: 128675.569 ns/op
Iteration 5: 125295.804 ns/op
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Result "org.apache.commons.lang3.math.FractionPowPerformanceTest.testNew":
125742.063 (99.9%) 6746.705 ns/op [Average]
(min, avg, max) = (124090.416, 125742.063, 128675.569), stdev = 1752.098
CI (99.9%): [118995.358, 132488.767] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_265, OpenJDK 64-Bit Server VM, 25.265-b01
# VM invoker: C:\jdk8u265-b01\jre\bin\java.exe
# VM options: -server -Xms2048M -Xms2048M
# Warmup: 5 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: org.apache.commons.lang3.math.FractionPowPerformanceTest.testOld
# Run progress: 50.00% complete, ETA 00:01:40
# Fork: 1 of 1
# Warmup Iteration 1: 135318.147 ns/op
# Warmup Iteration 2: 133351.865 ns/op
# Warmup Iteration 3: 134188.392 ns/op
# Warmup Iteration 4: 133996.330 ns/op
# Warmup Iteration 5: 135188.800 ns/op
Iteration 1: 134099.421 ns/op
Iteration 2: 136008.100 ns/op
Iteration 3: 135618.528 ns/op
Iteration 4: 135300.828 ns/op
Iteration 5: 135550.413 ns/op
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Result "org.apache.commons.lang3.math.FractionPowPerformanceTest.testOld":
135315.458 (99.9%) 2793.886 ns/op [Average]
(min, avg, max) = (134099.421, 135315.458, 136008.100), stdev = 725.563
CI (99.9%): [132521.572, 138109.344] (assumes normal distribution)
# Run complete. Total time: 00:03:21
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
FractionPowPerformanceTest.testNew avgt 5 125742.063 6746.705 ns/op
FractionPowPerformanceTest.testOld avgt 5 135315.458 2793.886 ns/op
7% faster.
Coverage decreased (-0.03%) to 94.672% when pulling 97388fde21a00bb7a25192bf70a059f8c46e8534 on XenoAmess:refine_Fraction.pow into 31dc5c700e1a08f4af33d94301ff06790533099b on apache:master.
[INFO] --- exec-maven-plugin:1.6.0:exec (benchmark) @ commons-lang3 ---
# JMH version: 1.21
# VM version: JDK 1.8.0_265, OpenJDK 64-Bit Server VM, 25.265-b01
# VM invoker: C:\jdk8u265-b01\jre\bin\java.exe
# VM options: -server -Xms2048M -Xms2048M
# Warmup: 5 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: org.apache.commons.lang3.math.FractionPowPerformanceTest.testNew
# Run progress: 0.00% complete, ETA 00:03:20
# Fork: 1 of 1
# Warmup Iteration 1: 16777.200 ns/op
# Warmup Iteration 2: 21455.564 ns/op
# Warmup Iteration 3: 16153.907 ns/op
# Warmup Iteration 4: 16037.464 ns/op
# Warmup Iteration 5: 16032.488 ns/op
Iteration 1: 16005.776 ns/op
Iteration 2: 16091.478 ns/op
Iteration 3: 15954.104 ns/op
Iteration 4: 16117.487 ns/op
Iteration 5: 16136.199 ns/op
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Result "org.apache.commons.lang3.math.FractionPowPerformanceTest.testNew":
16061.009 卤(99.9%) 299.825 ns/op [Average]
(min, avg, max) = (15954.104, 16061.009, 16136.199), stdev = 77.864
CI (99.9%): [15761.183, 16360.834] (assumes normal distribution)
# JMH version: 1.21
# VM version: JDK 1.8.0_265, OpenJDK 64-Bit Server VM, 25.265-b01
# VM invoker: C:\jdk8u265-b01\jre\bin\java.exe
# VM options: -server -Xms2048M -Xms2048M
# Warmup: 5 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: org.apache.commons.lang3.math.FractionPowPerformanceTest.testOld
# Run progress: 50.00% complete, ETA 00:01:40
# Fork: 1 of 1
# Warmup Iteration 1: 79713.217 ns/op
# Warmup Iteration 2: 80156.329 ns/op
# Warmup Iteration 3: 76097.612 ns/op
# Warmup Iteration 4: 75454.611 ns/op
# Warmup Iteration 5: 77729.279 ns/op
Iteration 1: 75950.798 ns/op
Iteration 2: 75840.056 ns/op
Iteration 3: 75355.666 ns/op
Iteration 4: 75309.956 ns/op
Iteration 5: 78419.559 ns/op
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Result "org.apache.commons.lang3.math.FractionPowPerformanceTest.testOld":
76175.207 卤(99.9%) 4953.771 ns/op [Average]
(min, avg, max) = (75309.956, 76175.207, 78419.559), stdev = 1286.479
CI (99.9%): [71221.436, 81128.979] (assumes normal distribution)
# Run complete. Total time: 00:03:21
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
FractionPowPerformanceTest.testNew avgt 5 16061.009 卤 299.825 ns/op
FractionPowPerformanceTest.testOld avgt 5 76175.207 卤 4953.771 ns/op
Hi. According to Gilles Sadowski's suggestions, I go to commons-numbers to learn about their version of Fraction, and re-refine the function. After the refine I achieved:
- It can still pass all exist tests
- It be 4.7 times faster than original.