Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Intl.Collator.compare vs localeCompare (numeric)
(version: 1)
Comparing performance of:
Intl.Collator vs localeCompare
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
const minCodePoint = 'a'.charCodeAt(0); const maxCodePoint = 'z'.charCodeAt(0); const randomLetter = () => String.fromCharCode(Math.floor(Math.random() * (maxCodePoint - minCodePoint) + minCodePoint)); const createWord = () => Array.from({length: 15}, randomLetter).join(''); var wordsCollator = Array.from({length: 50000}, createWord); var wordsLocale = [...wordsCollator]; const collator = new Intl.Collator({numeric:true});
Tests:
Intl.Collator
wordsCollator.sort(collator.compare);
localeCompare
wordsLocale.sort((a, b) => a.localeCompare(b, {numeric:true}))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Intl.Collator
localeCompare
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Browser/OS:
Chrome 134 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Intl.Collator
404.3 Ops/sec
localeCompare
7.4 Ops/sec
Related benchmarks:
Substring Test
Intl.Collator.compare() vs localeCompare() no options sort
sillyString 2
Intl.Collator.compare vs localeCompare
Intl.Collator.compare vs localeCompare 2
Intl.Collator.compare vs localeCompare (fixed)
Meowww
Intl.Collator.compare vs localeCompare with numbers
Intl.Collator('en').compare vs localeCompare
Comments
Confirm delete:
Do you really want to delete benchmark?