Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Intl.Collator.compare vs localeCompare with options
(version: 1)
Comparing performance of:
Intl.Collator vs localeCompare
Created:
12 days ago
by:
Guest
Go 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 words = Array.from({length: 50000}, createWord);
Tests:
Intl.Collator
const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base', }); words.sort(collator.compare);
localeCompare
words.sort((a, b) => a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base', }))
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:
12 days ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36
Browser/OS:
Chrome 149 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Intl.Collator
287/s
localeCompare
7/s
View exact numbers
Test name
Executions per second
✓
Intl.Collator
287 Ops/sec
localeCompare
7 Ops/sec
Related benchmarks
Intl.Collator.compare() vs localeCompare() no options sort
Intl.Collator.compare vs localeCompare
Intl.Collator.compare vs localeCompare (fixed)
Meowww
Intl.Collator.compare vs localeCompare with numbers
Intl.Collator('en').compare vs localeCompare
Intl.Collator.compare vs localeCompare (numeric)
Comments
Confirm delete:
Do you really want to delete benchmark?