kentcdodds / match-sorter

Simple, expected, and deterministic best-match sorting of an array in JavaScript

Home Page:https://npm.im/match-sorter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

mech opened this issue · comments

commented
  • match-sorter version: 6.3.1
  • node version: 14.17.0

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?

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!

@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!