Tests:

Historical Performance Data aggregated from 25 community runs

Desktop Results:
Chrome 19 runs
Math.random()
13.1M/s
crypto.getRandomValues()
703K/s

Fastest: Math.random() (18.7x faster)

View exact numbers
  • Math.random(): 13,107,916 ops/sec
  • crypto.getRandomValues(): 702,677 ops/sec
Firefox 6 runs
Math.random()
1387.6M/s
crypto.getRandomValues()
1.7M/s

Fastest: Math.random() (830.6x faster)

View exact numbers
  • Math.random(): 1,387,567,488 ops/sec
  • crypto.getRandomValues(): 1,670,575 ops/sec

Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.

Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results
  • Test case name Result
    Math.random()
    crypto.getRandomValues()

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:139.0) Gecko/20100101 Firefox/139.0
Firefox 139 on Windows
View result in a separate tab
Math.random()
2599.1M/s
crypto.getRandomValues()
1.8M/s
View exact numbers
Test name Executions per second
Math.random() 2,599,081,216 Ops/sec
crypto.getRandomValues() 1,804,638 Ops/sec