RFR: 8283681: Improve ZonedDateTime offset handling [v2]
Claes Redestad
redestad at openjdk.java.net
Fri Mar 25 14:35:47 UTC 2022
On Fri, 25 Mar 2022 14:09:03 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
>> Claes Redestad has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Add nanoOfSecond parameter, make micro less reliant on constants
>
> src/java.base/share/classes/java/time/ZoneRegion.java line 183:
>
>> 181: @Override
>> 182: /* package-private */ ZoneOffset getOffset(long epochSecond) {
>> 183: return getRules().getOffset(Instant.ofEpochSecond(epochSecond));
>
> The nanoAdjustment passed to `ofEpochSecond` is discarded in this code.
> It may be larger than a second; see `Instant.ofEpochSecond(sec, nano)` for the details.
> Adding a second parameter to the `getOffset` method could be the remedy.
Done.
Sadly it seems the smaller improvement I got on `getYearFromMillisZoneRegion/-UTC` was due avoiding the added arithmetic in `Instant.ofEpochSecond(sec, nanos)`:
Benchmark Mode Cnt Score Error Units
GetYearBench.getYearFromMillisZoneOffset thrpt 15 27.579 ? 0.030 ops/ms
GetYearBench.getYearFromMillisZoneRegion thrpt 15 9.570 ? 0.091 ops/ms
GetYearBench.getYearFromMillisZoneRegionUTC thrpt 15 28.063 ? 0.030 ops/ms
Benchmark Mode Cnt Score Error Units
GetYearBench.getYearFromMillisZoneOffset thrpt 15 34.791 ? 0.030 ops/ms
GetYearBench.getYearFromMillisZoneRegion thrpt 15 9.526 ? 0.122 ops/ms
GetYearBench.getYearFromMillisZoneRegionUTC thrpt 15 28.056 ? 0.040 ops/ms
`getYearFromMillisZoneOffset` is still good.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7957
More information about the core-libs-dev
mailing list