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 (Android 10; Mobile; rv:122.0) Gecko/122.0 Firefox/122.0
Browser:
Firefox Mobile 122
Operating system:
Android
Device Platform:
Mobile
Date tested:
2 years ago
Test name
Executions per second
math
374956.6 Ops/sec
crypto
60386.4 Ops/sec
crypto Number to String
55851.3 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()