Script Preparation code:
x
 
const TWO_DIGIT = '2-digit';
var options = {
      month: TWO_DIGIT,
      year: 'numeric',
      day: TWO_DIGIT,
      hour: TWO_DIGIT,
      hour12: false,
      minute: TWO_DIGIT,
      second: TWO_DIGIT,
    }
var cached = new Intl.DateTimeFormat('en-US', options);
Tests:
  • new Intl.DateTimeFormat.format()

     
    new Intl.DateTimeFormat('en-US', options).format(new Date());
  • cached Intl.DateTimeFormat.format()

     
    cached.format(new Date());
  • new Intl.DateTimeFormat.formatToParts

     
    new Intl.DateTimeFormat('en-US', options).formatToParts(new Date());
  • cached Intl.DateTimeFormat.formatToParts()

     
    cached.formatToParts(new Date());
  • date methods

     
    new Date().toLocaleString('en-US', options);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    new Intl.DateTimeFormat.format()
    cached Intl.DateTimeFormat.format()
    new Intl.DateTimeFormat.formatToParts
    cached Intl.DateTimeFormat.formatToParts()
    date methods

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 29 days ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Chrome 134 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
new Intl.DateTimeFormat.format() 28492.4 Ops/sec
cached Intl.DateTimeFormat.format() 860373.1 Ops/sec
new Intl.DateTimeFormat.formatToParts 29007.0 Ops/sec
cached Intl.DateTimeFormat.formatToParts() 371481.3 Ops/sec
date methods 28212.4 Ops/sec