Skip to content

Frontend/perf: Cache Intl.DateTimeFormat objects for perf #8021

Description

@tristanlabelle

From https://www.measurethat.net/Benchmarks/Show/17387/0/new-intldatetimeformat-vs-cached-intldatetimeformat , creating new object every time is 40x slower.

method perf
new Intl.DateTimeFormat.format() new Intl.DateTimeFormat.format() x 22,089 ops/sec ±7.01% (54 runs sampled)
cached Intl.DateTimeFormat.format() cached Intl.DateTimeFormat.format() x 889,643 ops/sec ±1.50% (62 runs sampled)
new Intl.DateTimeFormat.formatToParts new Intl.DateTimeFormat.formatToParts x 23,714 ops/sec ±2.14% (56 runs sampled)
cached Intl.DateTimeFormat.formatToParts() cached Intl.DateTimeFormat.formatToParts() x 369,974 ops/sec ±2.42% (54 runs sampled)

Metadata

Metadata

Labels

i18nInternationalization / localization issue

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions