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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0
Browser:
Chrome 128
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
math
38002.8 Ops/sec
crypto
29450.2 Ops/sec
crypto Number to String
30106.1 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()