Script Preparation code:
Tests:
  • Math.random().toString(36).slice(-5)

  • (+new Date).toString(36).slice(-5)

  • btoa(Math.random()).slice(0, 5)

  • btoa(+new Date).slice(-7, -2)

  • btoa(+new Date).substr(-7, 5)

Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results
  • Test case name Result
    Math.random().toString(36).slice(-5)
    (+new Date).toString(36).slice(-5)
    btoa(Math.random()).slice(0, 5)
    btoa(+new Date).slice(-7, -2)
    btoa(+new Date).substr(-7, 5)

    Fastest: N/A

    Slowest: N/A

Get performance results from real users on your website with Request Metrics.
Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36
Chrome 93 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Math.random().toString(36).slice(-5) 3315275.0 Ops/sec
(+new Date).toString(36).slice(-5) 1857315.0 Ops/sec
btoa(Math.random()).slice(0, 5) 1069847.0 Ops/sec
btoa(+new Date).slice(-7, -2) 2213181.0 Ops/sec
btoa(+new Date).substr(-7, 5) 2247551.0 Ops/sec