RFR: 8315585: Optimization for decimal to string
温绍锦
duke at openjdk.org
Wed Oct 4 23:11:27 UTC 2023
I submitted PR #15555 before, and there were too many changes. I split it into multiple PRs with small changes. This one is one of them.
this PR removed the duplicate code for getChars in BigDecimal#StringBuilderHelper, i also make performance faster, Here are the numbers run on a MacBook M1 Pro:
-Benchmark Mode Cnt Score Error Units (baseline)
-BigDecimals.testHugeToEngineeringString avgt 15 228.102 ? 12.568 ns/op
-BigDecimals.testLargeToEngineeringString avgt 15 53.814 ? 0.180 ns/op
-BigDecimals.testSmallToEngineeringString avgt 15 17.521 ? 0.521 ns/op
-BigDecimals.testToEngineeringString avgt 15 1814.858 ? 64.432 ns/op
+Benchmark Mode Cnt Score Error Units ()
+BigDecimals.testHugeToEngineeringString avgt 15 209.579 ? 5.037 ns/op (+8.84)
+BigDecimals.testLargeToEngineeringString avgt 15 29.617 ? 0.557 ns/op (+81.70)
+BigDecimals.testSmallToEngineeringString avgt 15 11.230 ? 0.075 ns/op (+56.02)
+BigDecimals.testToEngineeringString avgt 15 1732.913 ? 33.629 ns/op (+4.73)
Please review and don't hesitate to critique my approach and patch.
-------------
Commit messages:
- optimize BigDecimal.toString
Changes: https://git.openjdk.org/jdk/pull/16006/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=16006&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8315585
Stats: 198 lines in 6 files changed: 121 ins; 59 del; 18 mod
Patch: https://git.openjdk.org/jdk/pull/16006.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/16006/head:pull/16006
PR: https://git.openjdk.org/jdk/pull/16006
More information about the core-libs-dev
mailing list