Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Intl.Collator.compare vs localeCompare with numbers
(version: 0)
Comparing performance of:
Intl.Collator vs localeCompare
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
const minCodePoint = 'a'.charCodeAt(0); const maxCodePoint = 'z'.charCodeAt(0); const randomTextNumber = () => 'tst-' + Math.floor(Math.random() * (1000 - 1) + 1); var words = Array.from({length: 50000}, randomTextNumber);
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:
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
540.2 Ops/sec
localeCompare
5.1 Ops/sec
Related benchmarks:
Intl.Collator.compare vs localeCompare
Intl.Collator.compare vs localeCompare 2
Intl.Collator.compare vs localeCompare (fixed)
Intl.Collator('en').compare vs localeCompare
Comments
Confirm delete:
Do you really want to delete benchmark?