Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
UUID Generation (compatibility mode) (fork)
(version: 0)
Comparing performance of:
Jeff Ward v7 vs Jon Surrell (not real UUID) vs Broofa (old) vs My Test vs Not even close to a UUID but good enough for my purposes
Created:
5 years ago
by:
Guest
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()); }; }()); function uiid() { return Date.now().toString(); }
Tests:
Jeff Ward v7
e7();
Jon Surrell (not real UUID)
guid();
Broofa (old)
uuidv4_old();
My Test
UUID.generate();
Not even close to a UUID but good enough for my purposes
uiid();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
Jeff Ward v7
Jon Surrell (not real UUID)
Broofa (old)
My Test
Not even close to a UUID but good enough for my purposes
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):
Let's dive into the world of UUID benchmarks! **Overview** The benchmark consists of four test cases, each generating a Unique Identifier (UUID). The test cases are: 1. **Jeff Ward v7**: Uses a custom implementation by Jeff Ward. 2. **Jon Surrell (not real UUID)**: Generates a string that resembles a UUID but is not a real one. 3. **Broofa (old)**: Uses an older implementation of generating a UUID. 4. **My Test**: A custom implementation by the test author. **Test Cases** Here's a brief explanation of each test case: 1. **Jeff Ward v7**: This test case uses a proprietary algorithm developed by Jeff Ward to generate a UUID. The generated UUID is stored in memory, and its execution count is measured. 2. **Jon Surrell (not real UUID)**: This test case generates a string that looks like a UUID but is not actually one. It's likely used as a baseline or comparison point for the other tests. 3. **Broofa (old)**: This test case uses an older algorithm to generate a UUID, which is now considered insecure and deprecated. 4. **My Test**: This test case uses a custom implementation by the test author to generate a UUID. **Key Observations** From the benchmark results, we can observe: * The execution count of each test case varies greatly across different browsers and devices. * The **Jeff Ward v7** test case generates a relatively high number of executions per second, likely due to its optimized algorithm. * The **Broofa (old)** test case produces the lowest number of executions per second, indicating that it's not suitable for use in performance-critical applications. * The **My Test** and **Jon Surrell (not real UUID)** test cases fall somewhere in between in terms of execution count. **UUID Generation Algorithms** Here's a brief analysis of each algorithm: 1. **Jeff Ward v7**: This implementation uses a combination of hashing and encoding to generate a UUID. It appears to be optimized for performance, producing high execution counts. 2. **Broofa (old)**: This older algorithm is likely based on the Microsoft Windows API, which generated UUIDs by combining version numbers with timestamp data. However, this approach has security vulnerabilities and is now considered deprecated. 3. **My Test**: The custom implementation by the test author uses a combination of random number generation and hashing to produce a UUID. While not optimized for performance, it appears to be secure. **Conclusion** The benchmark highlights the importance of using secure and efficient algorithms when generating UUIDs. The **Jeff Ward v7** test case demonstrates an optimized approach, while the **Broofa (old)** test case serves as a cautionary example of older algorithms with security vulnerabilities. The custom implementation by the test author shows that it's possible to create a secure and efficient UUID generator without relying on proprietary or deprecated algorithms.
Related benchmarks:
UUID Generation
UUID Generation (compatibility mode)
UUID Generation 2
UUID V4 Crypto vs Math
Comments
Confirm delete:
Do you really want to delete benchmark?