kentcdodds / match-sorter

Simple, expected, and deterministic best-match sorting of an array in JavaScript
https://npm.im/match-sorter
MIT License
3.73k stars 129 forks source link

What is the maximum array count for this sorter to perform well? #131

Closed mech closed 3 years ago

mech commented 3 years ago

Relevant code or config

// With 500K items of 17MB file is slow
matchSorter(items, inputValue);

// Using this is fast
items.filter(item => item.toLowerCase().includes(inputValue.toLowerCase()))

What you did:

Do a simple item search.

What happened:

Was expecting performance to be somewhat still ok compare to basic CONTAINS method.

What is the ideal maximum array count before the sorting become very laggy and are there any optimization we can make ourselves?

kentcdodds commented 3 years ago

Hi @mech,

You'll have to do your own testing. I had 16k items to search through once and needed to put it into a web worker (both the items and match-sorter) to make the app responsive when searching. That worked pretty well.

Unfortunately there's nothing actionable in this issue so I'm going to close it. Good luck!

Sigfried commented 1 year ago

@kentcdodds

You'll have to do your own testing. I had 16k items to search through once and needed to put it into a web worker (both the items and match-sorter) to make the app responsive when searching. That worked pretty well.

Can you provide an example of how to do that? I have 7K items and need to do something about performance. Thank you!

kentcdodds commented 1 year ago

I used a webpack loader called workerize. https://github.com/kentcdodds/react-performance/blob/main/src/workerized-filter-cities.js