Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
new Intl.NumberFormat vs cached instances
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/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
new Intl.NumberFormat
59928.3 Ops/sec
memoized instance
58598.6 Ops/sec
Script Preparation code:
window.cache = new WeakMap(); window.format = (locale, currency, value) => new Intl.NumberFormat(locale, { style: 'currency', currency }).format(value); window.memoizedFormat = (locale, currency, value) => { const key = [locale, currency]; let formatter = window.cache.get(key); if (!formatter) { formatter = new Intl.NumberFormat(locale, { style: 'currency', currency }); window.cache.set(key, formatter); } return formatter.format(value); };
Tests:
new Intl.NumberFormat
window.format('pt-BR', 'BRL', 100_346_999.21);
memoized instance
window.memoizedFormat('pt-BR', 'BRL', 100_346_999.21);