Skip to content

fix(#632) - Locale pipe optimization#637

Open
ben12 wants to merge 2 commits into
jsverse:masterfrom
ben12:ben12/issue632
Open

fix(#632) - Locale pipe optimization#637
ben12 wants to merge 2 commits into
jsverse:masterfrom
ben12:ben12/issue632

Conversation

@ben12

@ben12 ben12 commented Mar 19, 2023

Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: #632

What is the new behavior?

Locale pipes return last formatted value when value and parameters do not change.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

Using this measurement code (and same for Date, Percent and Currency):

    pipe = new TranslocoDecimalPipe(service, cdr, defaultConfig.localeConfig);

    const config = { useGrouping: true, maximumFractionDigits: 3 };
    
    const start = performance.now();
    for(let i = 0; i < 100000; i++) {
      pipe.transform('123', config);
    }
    const end = performance.now();
    console.log(`Decimal Execution time: ${end - start} ms`);

Before optimization I get:

LOG: 'Decimal Execution time: 1708.9000000059605 ms'
LOG: 'Date Execution time: 7880.100000008941 ms'
LOG: 'Percent Execution time: 1741.4000000059605 ms'
LOG: 'Currency Execution time: 2233.5 ms'

After optimization I get:

LOG: 'Decimal Execution time: 35.19999998807907 ms'
LOG: 'Date Execution time: 47.599999994039536 ms'
LOG: 'Percent Execution time: 34.900000005960464 ms'
LOG: 'Currency Execution time: 38.70000000298023 ms'

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@ben12

ben12 commented May 16, 2023

Copy link
Copy Markdown
Contributor Author

@shaharkazaz Ready for review

@shaharkazaz

Copy link
Copy Markdown
Collaborator

@ben12 Thank you for the PR and the heads up, I missed this PR.
IDK when I'll be able to review but I'll try to reach it as soon as I have the time!

@ben12 ben12 force-pushed the ben12/issue632 branch 2 times, most recently from e5e9a70 to 284694c Compare October 26, 2023 19:05
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.

2 participants