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:
2 years ago
random()
9.5M/s
Math.random()
6.9M/s
View exact numbers
Test name
Executions per second
✓
random()
9,486,525 Ops/sec
Math.random()
6,909,006 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()