Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Search - Intl.Collator vs localeCompare vs normalize
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/128.0.0.0 Safari/537.36
Browser:
Chrome 128
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Intl.Collator
1473480.5 Ops/sec
localeCompare
146936.3 Ops/sec
normalized
471849.2 Ops/sec
Script Preparation code:
var subject = 'Éclate lécrou, déchire la feuille, repara la máquina, recalienta la sopa, decora la habitación, despierta, spettacolo, überlegen, piękny, szczęście, υπέροχος.'; var needle = 'on'; var options = { usage: 'search', sensitivity: 'base' }; var collator = new Intl.Collator(undefined, options); function normalizeText(text) { return text.normalize('NFD').replace(/[\u0300-\u036f]/g, "").toLowerCase(); } function searchWithNormalizedText(string, query) { const nString = normalizeText(string); const nQuery = normalizeText(query); return nString.includes(nQuery); }
Tests:
Intl.Collator
collator.compare(subject.toLowerCase(), needle.toLowerCase());
localeCompare
subject.toLowerCase().localeCompare(needle.toLowerCase(), undefined, options);
normalized
searchWithNormalizedText(subject, needle);