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

fix: improved performance of formatters #818

Merged
merged 3 commits into from
Nov 3, 2020

Conversation

semoal
Copy link
Contributor

@semoal semoal commented Nov 3, 2020

Will close #472

I've added to format functions a third param to disable/enable the memoize function for testing purposes in that way we can be 100% sure that the cache is working properly.

Some results (1000x renders of date)

    ┌──────────────────────┬────────────────────┐
    │       (index)        │       Values       │
    ├──────────────────────┼────────────────────┤
    │  memoizedDateResult  │  6.58090500000003  │
    │ withoutMemoizeResult │ 263.14999799999987 │
    └──────────────────────┴────────────────────┘

Some results (1000x renders of number)

    ┌──────────────────────┬────────────────────┐
    │       (index)        │       Values       │
    ├──────────────────────┼────────────────────┤
    │ memoizedNumberResult │ 2.9453200000002653 │
    │ withoutMemoizeResult │ 45.79147499999999  │
    └──────────────────────┴────────────────────┘

@vercel
Copy link

vercel bot commented Nov 3, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/lingui-js/js-lingui/7w4ggsq7k
✅ Preview: https://js-lingui-git-memoize-formatters.lingui-js.vercel.app

@tricoder42
Copy link
Contributor

Awesome! Pretty good performance boost 👍

@codecov
Copy link

codecov bot commented Nov 3, 2020

Codecov Report

Merging #818 into main will increase coverage by 0.10%.
The diff coverage is 92.59%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #818      +/-   ##
==========================================
+ Coverage   84.71%   84.81%   +0.10%     
==========================================
  Files          39       39              
  Lines        1295     1317      +22     
  Branches      341      349       +8     
==========================================
+ Hits         1097     1117      +20     
- Misses        117      118       +1     
- Partials       81       82       +1     
Impacted Files Coverage Δ
packages/core/src/formats.ts 90.00% <92.59%> (+2.50%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 49f45b2...733af20. Read the comment docs.

@tricoder42 tricoder42 merged commit 22667ad into lingui:main Nov 3, 2020
@tricoder42
Copy link
Contributor

Nice! Looks good to me 🚀

@semoal semoal deleted the memoize-formatters branch November 3, 2020 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance issues with formatters
2 participants