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 (Windows NT 5.1; rv:52.0) Gecko/20100101 Firefox/52.0
Browser:
Firefox 52
Operating system:
Windows XP
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Math.random()
185686592.0 Ops/sec
random()
10589471.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()