Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Math.random() vs. random() v2
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36
Browser:
Chrome 125
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Math.random()
6909006.5 Ops/sec
random()
9486525.0 Ops/sec
Script Preparation code:
var random = (() => { const MAX = 2 ** 32 - 1; const pool = crypto.getRandomValues(new Uint32Array(1024)); // 4MB let index = 0; return () => { const value = pool[index]; index++; if (index === pool.length) { crypto.getRandomValues(pool); index = 0; } return value / MAX; }; })();
Tests:
Math.random()
Math.random()
random()
random()