Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Test UUID with more optimizations
(version: 0)
Comparing performance of:
1 vs 2 vs 3 vs 4 vs 5 vs 6 vs 7 vs 8
Created:
3 years ago
by:
Guest
Jump to the latest result
Tests:
1
const generateUUID = () => ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, e => // eslint-disable-next-line no-bitwise (e ^ ((window.crypto || window.msCrypto).getRandomValues(new Uint8Array(1))[0] & (15 >> (e / 4)))).toString(16) ); generateUUID();
2
function uuid() { let uuid = "", i, random; for (i = 0; i < 32; i++) { random = (Math.random() * 16) | 0; if (i == 8 || i == 12 || i == 16 || i == 20) { uuid += "-"; } uuid += (i == 12 ? 4 : i == 16 ? (random & 3) | 8 : random).toString(16); } return uuid; } uuid();
3
function uuid1(a) { return a ? (a ^ ((Math.random() * 16) >> (a / 4))).toString(16) : ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, uuid1); } uuid1()
4
var IDX=256, HEX=[], BUFFER; while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1); function v4() { var i=0, num, out=''; if (!BUFFER || ((IDX + 16) > 256)) { BUFFER = Array(i=256); while (i--) BUFFER[i] = 256 * Math.random() | 0; i = IDX = 0; } for (; i < 16; i++) { num = BUFFER[IDX + i]; if (i==6) out += HEX[num & 15 | 64]; else if (i==8) out += HEX[num & 63 | 128]; else out += HEX[num]; if (i & 1 && i > 1 && i < 11) out += '-'; } IDX++; return out; } v4();
5
const ui8a = new Uint8Array(1); var IDX=256, HEX=[], BUFFER = Array(IDX); while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1); function v4() { var i=0, num, out=''; if ((IDX + 16) > 256) { while (i--) BUFFER[i] = 256 * crypto.getRandomValues(ui8a)[0] | 0; i = IDX = 0; } for (; i < 16; i++) { num = BUFFER[IDX + i]; if (i==6) out += HEX[num & 15 | 64]; else if (i==8) out += HEX[num & 63 | 128]; else out += HEX[num]; if (i & 1 && i > 1 && i < 11) out += '-'; } IDX++; return out; } v4();
6
const ui8a = new Uint8Array(1); function uuid() { let uuid = "", i, random; for (i = 0; i < 32; i++) { random = (crypto.getRandomValues(ui8a)[0] * 16) | 0; if (i == 8 || i == 12 || i == 16 || i == 20) { uuid += "-"; } uuid += (i == 12 ? 4 : i == 16 ? (random & 3) | 8 : random).toString(16); } return uuid; } uuid();
7
const ui8a = new Uint8Array(1); function uuid() { let uuid = "00000000-000-000-000-00000000000", i, random; for (i = 0; i < 32; i++) { random = (crypto.getRandomValues(ui8a)[0] * 16) | 0; if (i === 8 || i === 12 || i === 16 || i === 20) continue; uuid[i] = (i == 12 ? 4 : i == 16 ? (random & 3) | 8 : random).toString(16); } return uuid; } uuid();
8
const ui8a = new Uint8Array(1); function uuid() { let uuid = "00000000-000-000-000-00000000000", i = 0, random; while(i < 32) { if (i === 8 || i === 12 || i === 16 || i === 20) { } else { random = (crypto.getRandomValues(ui8a)[0] * 16) | 0; uuid[i] = (i === 12 ? 4 : i === 16 ? (random & 3) | 8 : random).toString(16); } i++; } return uuid; } uuid();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (8)
Previous results
Fork
Test case name
Result
1
2
3
4
5
6
7
8
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
A mysterious and cryptic message! After analyzing the text, I noticed that it seems to be a JavaScript function that generates a unique identifier (UUID) and then executes this function multiple times with different `TestName` values. The UUID generation part appears to be using a combination of bitwise operations on a random number generated by `crypto.getRandomValues`. The resulting string is likely a valid UUID. As for the actual question, I'm going to take a wild guess: Are you asking me to predict or infer something about the behavior or usage of this JavaScript function based on its output? If so, I'll need more context or information about what you're trying to achieve or understand. Perhaps there's a specific aspect of the function's behavior that you'd like me to analyze or interpret?
Related benchmarks:
UUID perf test
Test UUID with different optimizations
Set string vs number
Set string vs number #1
Set string vs number (100k)
Comments
Confirm delete:
Do you really want to delete benchmark?