Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
UUID V4 Crypto vs Math
Crypto.getRandomValues vs Math.random
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Browser:
Chrome 119
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
math
116921.0 Ops/sec
crypto
47422.9 Ops/sec
crypto Number to String
52940.5 Ops/sec
Script Preparation code:
function uuidCrypto() { let bytes = window.crypto.getRandomValues(new Uint8Array(32)); const randomBytes = () => (bytes = bytes.slice(1)) && bytes[0]; return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => (c ^ randomBytes() & 15 >> c / 4).toString(16)) } function uuidMath() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => { const r = (Math.random() * 16) | 0; const v = c === 'x' ? r : (r & 0x3) | 0x8; return v.toString(16); }); } function uuidCryptoNumber() { let bytes = window.crypto.getRandomValues(new Uint8Array(32)); const randomBytes = () => (bytes = bytes.slice(1)) && bytes[0]; return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => (c ^ randomBytes() & 15 >> c / 4).toString(16) ); }
Tests:
math
uuidMath()
crypto
uuidCrypto()
crypto Number to String
uuidCryptoNumber()