Skip to content

Conversation

@Avasam
Copy link

@Avasam Avasam commented Sep 20, 2022

Same as react-bootstrap-table#1627

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 Avasam force-pushed the speedup-splitNested branch from d7092aa to f52239a Compare September 20, 2022 02:15
@Avasam Avasam force-pushed the speedup-splitNested branch from f52239a to 847df15 Compare July 8, 2023 18:52
@Avasam
Copy link
Author

Avasam commented Jul 8, 2023

Mind a review?

@Avasam
Copy link
Author

Avasam commented Aug 18, 2024

@murasoftware bump

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.

1 participant