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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36
Browser:
Chrome 150
Operating system:
Windows
Device Platform:
Desktop
Date tested:
16 days ago
With simple cache
2.0M/s
No caching
31K/s
View exact numbers
Test name
Executions per second
✓
With simple cache
1,978,917 Ops/sec
No caching
30,638 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())