This is part of a series of PRs based on performance work we have done to
improve a use-case involving parsing/formatting hundreds of thousands of dates
where luxon was the bottleneck.
Previously we guessed by calling zone.offset(tsNow) on every
construction of a date from date parts. This caches that result instead,
saving a call to offset. The tests verify that this works across DST boundaries when the cache holds an offset for the previous DST state from now.
For processes that live across a DST boundary and mostly handle current date times, this will mean the guess is wrong and we'll have to re-guess. Since we're caching one call to offset, this should be performance neutral to current behavior. Otherwise, we save a call.
Benchmark Comparison (name | before | after | after/before):
DateTime.local with numbers and zone | 50,913 ±0.18% | 66,168 ±0.25% | 1.3x
This is part of a series of PRs based on performance work we have done to improve a use-case involving parsing/formatting hundreds of thousands of dates where luxon was the bottleneck.
This includes the commit from https://github.com/moment/luxon/pull/1574 to establish the benchmark
Previously we guessed by calling zone.offset(tsNow) on every construction of a date from date parts. This caches that result instead, saving a call to offset. The tests verify that this works across DST boundaries when the cache holds an offset for the previous DST state from now.
For processes that live across a DST boundary and mostly handle current date times, this will mean the guess is wrong and we'll have to re-guess. Since we're caching one call to offset, this should be performance neutral to current behavior. Otherwise, we save a call.
Benchmark Comparison (
name | before | after | after/before
):