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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Browser:
Chrome 143
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
3 months ago
Test name
Executions per second
Intl.Collator.compare (ASCII-only strings)
496.4 Ops/sec
String.prototype.localeCompare (ASCII-only strings)
877.0 Ops/sec
Intl.Collator.compare
329.1 Ops/sec
String.prototype.localeCompare
273.8 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));