Skip to content

Conversation

Avasam
Copy link

@Avasam Avasam commented May 20, 2021

I've started experiencing really bad delay when changing page in my table whenever sorting by a string value column. I found the splitNested function to be the culprit. See 2 perf screenshots below

SplitNested is slow 1 SplitNested is slow 2

It seems to be doing some useless actions, like joining on an array of 1 string and replacing text in multiple iterations.
I also did my best to optimize the regex without affecting functionality.
Here are some performance comparisons from JSBench.Me:
splitNested Optimisation test results

And the new real-world performance results:
splitNested Optimized results

Finally, I've used a better string comparison for very large array of strings. namely Intl.Collator instead of localeCompare.
See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare#performance
(I haven't yet recorded performance comparison)

@Avasam
Copy link
Author

Avasam commented Jul 8, 2023

Mind a review?

@Avasam
Copy link
Author

Avasam commented Aug 18, 2024

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