Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Intl.Collator.compare vs String.prototype.localeCompare (v8 ASCII fast path)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0
Browser:
Firefox 125
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Intl.Collator.compare (ASCII-only strings)
175.5 Ops/sec
String.prototype.localeCompare (ASCII-only strings)
150.9 Ops/sec
Intl.Collator.compare
146.7 Ops/sec
String.prototype.localeCompare
123.9 Ops/sec
Script Preparation code:
function randomStrings(chars, length, stringLength) { const randomChar = () => chars[Math.floor(Math.random() * chars.length)]; const randomString = () => Array.from({length: stringLength}, randomChar).join(""); return Array.from({length}, randomString); } var asciiStrings = randomStrings(["a", "b", "c"], 50000, 9); var unicodeStrings = randomStrings(["간", "쟁", "뜻"], 50000, 9);
Tests:
Intl.Collator.compare (ASCII-only strings)
const collator = new Intl.Collator(); asciiStrings.sort(collator.compare);
String.prototype.localeCompare (ASCII-only strings)
asciiStrings.sort((a, b) => a.localeCompare(b));
Intl.Collator.compare
const collator = new Intl.Collator(); unicodeStrings.sort(collator.compare);
String.prototype.localeCompare
unicodeStrings.sort((a, b) => a.localeCompare(b));