Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LANG-1601] Refine performance of fraction.pow #611

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

XenoAmess
Copy link
Contributor

No description provided.

@XenoAmess

This comment has been minimized.

@coveralls
Copy link

coveralls commented Aug 24, 2020

Coverage Status

Coverage decreased (-0.03%) to 94.672% when pulling 97388fd on XenoAmess:refine_Fraction.pow into 31dc5c7 on apache:master.

@XenoAmess
Copy link
Contributor Author

[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

@XenoAmess
Copy link
Contributor Author

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:

  1. It can still pass all exist tests
  2. It be 4.7 times faster than original.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants