Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance when validating the same timezones many times #135

Closed
wants to merge 1 commit into from

Conversation

billthornton
Copy link

Hello 👋

Firstly thanks for this project, it's much needed.

When upgrading to the latest version we found a reduction in performance where we were using utcToZonedTime() on many dates.

It looks like the improvement to use Intl.DateTimeFormat (in #129) for validating timezone strings came with a performance cost.

This PR looks to cache valid IANA timezones to improve performance when validating the same timezone many times.

For example, calling tzParseTimezone 100 times with the same America/New_York timezone, this PR takes it down from ~17-19ms back down to 3-4ms.

The other file changes look just from the linting being run on the file.

Thanks!

@marnusw marnusw closed this in f26447b Sep 11, 2021
@marnusw
Copy link
Owner

marnusw commented Sep 11, 2021

Thank you @billthornton. I think using an object cache will be slightly more performant than the linear array search. (Although it's probably just academic.) I've added that optimisation and it will be released in an upcoming version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants