Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
UUID Generation (compatibility mode)
(version: 0)
Comparing performance of:
Jeff Ward v7 vs Jon Surrell (not real UUID) vs Broofa (old) vs My Test
Created:
8 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
// Jeff Ward v7 var lut = []; for (var i=0; i<256; i++) { lut[i] = (i<16?'0':'')+(i).toString(16); } function e7() { var d0 = Math.random()*0xffffffff|0; var d1 = Math.random()*0xffffffff|0; var d2 = Math.random()*0xffffffff|0; var d3 = Math.random()*0xffffffff|0; return lut[d0&0xff]+lut[d0>>8&0xff]+lut[d0>>16&0xff]+lut[d0>>24&0xff]+'-'+ lut[d1&0xff]+lut[d1>>8&0xff]+'-'+lut[d1>>16&0x0f|0x40]+lut[d1>>24&0xff]+'-'+ lut[d2&0x3f|0x80]+lut[d2>>8&0xff]+'-'+lut[d2>>16&0xff]+lut[d2>>24&0xff]+ lut[d3&0xff]+lut[d3>>8&0xff]+lut[d3>>16&0xff]+lut[d3>>24&0xff]; } // Broofa (old) function uuidv4_old() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); } // Jon Surrell (not real UUID) function guid() { function s4() { return Math.floor((1 + Math.random()) * 0x10000) .toString(16) .substring(1); } return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); } // My Test var UUID = (new function() { this._lut = []; for (var i = 0; i < 256; i++) { this._lut[i] = (i < 16 ? '0' : '') + (i).toString(16); }; this._format = function (rarr) { return '' + this._lut[rarr[0] & 0xff] + this._lut[rarr[0] >> 8 & 0xff] + this._lut[rarr[0] >> 16 & 0xff] + this._lut[rarr[0] >> 24 & 0xff] + '-' + this._lut[rarr[1] & 0xff] + this._lut[rarr[1] >> 8 & 0xff] + '-' + this._lut[rarr[1] >> 16 & 0x0f | 0x40] + this._lut[rarr[1] >> 24 & 0xff] + '-' + this._lut[rarr[2] & 0x3f | 0x80] + this._lut[rarr[2] >> 8 & 0xff] + '-' + this._lut[rarr[2] >> 16 & 0xff] + this._lut[rarr[2] >> 24 & 0xff] + this._lut[rarr[3] & 0xff] + this._lut[rarr[3] >> 8 & 0xff] + this._lut[rarr[3] >> 16 & 0xff] + this._lut[rarr[3] >> 24 & 0xff]; }; this._getRandomness = function () { if ('crypto' in window && 'Uint32Array' in window) { var dvals = new Uint32Array(4); window.crypto.getRandomValues(dvals); return dvals } return [ Math.random() * 0x100000000 >>> 0, Math.random() * 0x100000000 >>> 0, Math.random() * 0x100000000 >>> 0, Math.random() * 0x100000000 >>> 0, ]; }; this.generate = function () { return this._format(this._getRandomness()); }; }());
Tests:
Jeff Ward v7
e7();
Jon Surrell (not real UUID)
guid();
Broofa (old)
uuidv4_old();
My Test
UUID.generate();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Jeff Ward v7
Jon Surrell (not real UUID)
Broofa (old)
My Test
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):
I'll break down the provided benchmark definition and individual test cases, explaining what's tested, compared, and their pros and cons. **Benchmark Definition:** The benchmark definition is a JavaScript function that generates a UUID (Universally Unique Identifier). There are four test cases: 1. **Jeff Ward v7**: This function uses a lookup table (`lut`) to generate the UUID. 2. **Jon Surrell (not real UUID)**: This function generates a UUID by concatenating four random numbers in hexadecimal format. 3. **Broofa (old)**: This is an older version of the `uuidv4` function, which also generates a UUID using a similar approach to Jeff Ward v7. 4. **My Test**: This custom implementation uses a similar approach as Jon Surrell but with some additional randomness generation. **Comparison:** * **Jeff Ward v7 vs Broofa (old)**: Both use a lookup table-based approach, which is efficient and predictable. However, the `broofa` function has a slightly different implementation. * **My Test vs Jeff Ward v7**: Both use a similar approach, but My Test uses more randomness generation, making it potentially faster. **Pros and Cons:** 1. **Jeff Ward v7**: * Pros: Efficient, predictable, and easy to understand. * Cons: May not be suitable for cryptographic purposes due to the fixed lookup table. 2. **Jon Surrell (not real UUID)**: * Pros: Simple, fast, and easy to implement. * Cons: Less efficient than other approaches, as it relies on concatenating random numbers. 3. **Broofa (old)**: * Pros: Similar to Jeff Ward v7, but with a slightly different implementation. * Cons: Also uses a fixed lookup table, which may not be suitable for cryptographic purposes. 4. **My Test**: * Pros: Combines the efficiency of Jeff Ward v7 with additional randomness generation, making it potentially faster than Jon Surrell (not real UUID). * Cons: More complex implementation due to the custom randomness generation. **Latest Benchmark Results:** The results show that: 1. **Jeff Ward v7**: Has the highest execution frequency per second. 2. **My Test**: Is close behind Jeff Ward v7, with a slightly lower but still high execution frequency. 3. **Broofa (old)** and **Jon Surrell (not real UUID)** have significantly lower execution frequencies. Overall, the benchmark results suggest that `Jeff Ward v7` is currently the fastest implementation among the four test cases, followed closely by `My Test`. However, it's essential to note that this may change as new browser versions or hardware are introduced.
Related benchmarks:
UUID Generation
UUID Generation 2
UUID V4 Crypto vs Math
UUID Generation (compatibility mode) (fork)
Comments
Confirm delete:
Do you really want to delete benchmark?