agencyenterprise / react-native-health

A React Native package to interact with Apple HealthKit
MIT License
799 stars 226 forks source link

improve perf 3-5x by avoiding re-instantiating date formatter #356

Open pelhage opened 6 months ago

pelhage commented 6 months ago

Description

Querying workouts was taking an unexpectedly long time, so did a perf trace, saw that this code was the culprit:

image

Modified the code and re-ran my project and saw huge savings.

TBH not sure if this needs more extensive testing (are there unit tests?), but feedback is welcome.

BEFORE:

image image image image

AFTER:

image image

Fixes # (issue)

Type of change

Please delete options that are not relevant.

Checklist: