17.7x speedup of Double.toString(double)

Raffaello Giulietti raffaello.giulietti at gmail.com
Mon Apr 20 12:33:29 UTC 2020


Hello,

curious about Double.toString(double) performance?

Here are the results obtained by jmh 1.23 on a recent changeset [1]. The 
benchmark is over the full range of bitwise uniformly distributed random 
doubles.


# VM options: <none>
# Warmup: 5 iterations, 10 s each
# Measurement: 5 iterations, 10 s each
...
Benchmark                     Mode  Cnt     Score     Error  Units
DoubleToStringBenchmark.test  avgt   25  1251.658 ± 211.068  ns/op

showing quite a variability, probably attributable to intervening gc cycles.



The same setup after the integration of the code in [2] to replace 
Double.toString(double) with a modern, better specified and correct 
implementation (as witnessed by many trillions of fully conformant 
outcomes).


# VM options: <none>
# Warmup: 5 iterations, 10 s each
# Measurement: 5 iterations, 10 s each
...
Benchmark                     Mode  Cnt   Score   Error  Units
DoubleToStringBenchmark.test  avgt   25  70.712 ± 1.461  ns/op

showing both a speedup of 17.7x on my i7 based laptop of 2013 as well as 
predictable running times. The algorithm never generates temporary garbage.



I'm still looking for enthusiastic reviewers: they seem hard to find, 
despite monthly reminders... More in [3] and similarly titled posts for 
the past 12 months.


Greetings
Raffaello

----

[1] https://hg.openjdk.java.net/jdk/jdk/rev/90882ba9f488
[2] https://cr.openjdk.java.net/~bpb/4511638/webrev.04/
[3] 
https://mail.openjdk.java.net/pipermail/core-libs-dev/2020-March/065476.html



More information about the core-libs-dev mailing list