Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR aims to optimise some of the most expensive operations:
constructUrl
,constructUrlFromParams
andextractQueryParams
. I’ve been experimenting with a few other things as well but I wanted to present them in a few small manageable PRs starting with the most expensive operations 🙂 That’s also to be able to see more clearly the result of each optimisation.Profiling results (on my laptop)
100,000 iterations each
Master
responsive: 2399.842ms
responsive with fixed height: 2748.130ms
responsive with aspect ratio: 2557.563ms
fixed width: 2088.678ms
fixed width with quality: 2383.402ms
fixed width with dpr quality disabled: 1984.050ms
fixed width with aspect ratio: 2111.138ms
Flamegrap
This PR
responsive: 1978.659ms
responsive with fixed height: 1850.560ms
responsive with aspect ratio: 2091.709ms
fixed width: 1672.963ms
fixed width with quality: 1714.667ms
fixed width with dpr quality disabled: 1624.185ms
fixed width with aspect ratio: 1802.629ms
Flamegraph
Profiling code