Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Intl.Collator.compare() vs localeCompare() - natural sort order
localeCompare is an abstraction of Intl.Collator, thus they can accept the same options. This test shows that using Intl.Collator is quicker for multiple comparisons.
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Browser:
Chrome 122
Operating system:
Windows
Device Platform:
Desktop
Date tested:
3 months ago
Test name
Executions per second
localeCompare()
168711.7 Ops/sec
Intl.Collator.compare()
4051390.5 Ops/sec
Script Preparation code:
var a = "z11"; var b = "z1"; var options = { sensitivity: 'base', numeric: true, }; var collator = new Intl.Collator(undefined, options);
Tests:
localeCompare()
a.localeCompare(b, undefined, options) === 1
Intl.Collator.compare()
collator.compare(a, b) === 1