Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Should you cache Intl.DateTimeFormat (simple key)?
Testing creating a new Intl.DateTimeFormat each time vs. caching it using simple string as the key.
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.1064 YaBrowser/23.9.1.1064 (beta) Yowser/2.5 Safari/537.36
Browser:
Yandex Browser 23
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
No caching
7513.3 Ops/sec
With simple cache
488701.8 Ops/sec
Script Preparation code:
FORMAT = { timeZone: 'Europe/Moscow', day: '2-digit', month: 'short', year: 'numeric' } cache = new Map()
Tests:
No caching
const date = new Intl.DateTimeFormat('en-AU', FORMAT).format(new Date())
With simple cache
const key = FORMAT.timeZone; let formatter = cache.get(key) if (!formatter) { formatter = new Intl.DateTimeFormat('en-AU', FORMAT) cache.set(key, formatter) } const date = formatter.format(new Date())