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:132.0) Gecko/20100101 Firefox/132.0
Browser:
Firefox 132
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Intl.Collator.compare (ASCII-only strings)
43.0 Ops/sec
String.prototype.localeCompare (ASCII-only strings)
36.5 Ops/sec
Intl.Collator.compare
28.5 Ops/sec
String.prototype.localeCompare
18.0 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));