RFR: 8263038: Optimize String.format for simple specifiers [v2]
Claes Redestad
redestad at openjdk.java.net
Mon Mar 8 16:38:07 UTC 2021
On Fri, 5 Mar 2021 16:36:19 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
>> Claes Redestad has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Lazily evaluate zero
>
> Looks good.
Piling on another optimization: The `getZero(..)` called eagerly in the constructor is rather expensive in non-US locales, e.g. running with "-Duser.language=fr":
Benchmark Mode Cnt Score Error Units
StringFormat.stringFormat avgt 5 924.536 ± 253.151 ns/op
Since the zero value is only used when printing floating point number I refactored so that the localized zero is evaluated lazily, which gets numbers on the micros in line with the numbers for a US locale:
Benchmark Mode Cnt Score Error Units
StringFormat.stringFormat avgt 5 291.385 ± 64.626 ns/op
-------------
PR: https://git.openjdk.java.net/jdk/pull/2830
More information about the core-libs-dev
mailing list