Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Generating element 'id' attributes
(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 domId(prefix) { return `${prefix}-${Math.round(Math.random() * Date.now()).toString(16)}`; }
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
domId('element');
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 break down the provided benchmark and explain what's being tested, compared, and their pros and cons. **Benchmark Overview** The provided JSON represents a JavaScript microbenchmarking test case. It contains four individual test cases, each with its own unique "Benchmark Definition" (a JavaScript function to be executed) and a brief description. The test cases are: 1. **Jeff Ward v7**: `e7();` 2. **Jon Surrell (not real UUID)**: `guid();` 3. **Broofa (old)**: `uuidv4_old();` 4. **My Test**: `UUID.generate();` **What's Being Tested** Each test case is designed to measure the execution time of a specific JavaScript function. The functions being executed are: 1. A custom UUID generator (`e7()`) by Jeff Ward. 2. A non-standard UUID generator (`guid()`). 3. An old, non-standard UUID generator (`uuidv4_old()`). 4. A custom UUID generator (`UUID.generate()`) implemented by the author. **Comparison** The test cases are compared to determine which one is the fastest in terms of execution time. The benchmarking results show the raw UA string (User Agent), browser version, device platform, operating system, and executions per second for each test case. **Pros and Cons of Each Test Case** Here's a brief analysis of each test case: 1. **Jeff Ward v7**: This custom UUID generator is optimized for performance. However, its implementation might be less straightforward than others. 2. **Jon Surrell (not real UUID)**: This non-standard UUID generator doesn't seem to follow standard UUID conventions. It might not be suitable for all use cases. 3. **Broofa (old)**: The old UUID generator uses a different approach that may not be efficient or secure. 4. **My Test**: The custom UUID generator implemented by the author is likely optimized for performance and follows standard UUID conventions. **Results** The latest benchmarking results show the following: * **Jeff Ward v7**: 5419882 executions per second (FPS) * **Jon Surrell (not real UUID)**: 2942699 FPS * **Not even close to a UUID but good enough for my purposes**: 772705 FPS * **Broofa (old)**: 375841.71875 FPS The results indicate that the custom UUID generator by Jeff Ward v7 is the fastest, followed closely by the "My Test" implementation. In conclusion, this benchmarking test case compares four unique JavaScript functions designed to generate UUIDs. The results highlight the performance differences between these implementations, with the custom UUID generator by Jeff Ward v7 being the fastest.
Related benchmarks:
pairs to object
forEach Lodash vs Vanilla
Deep Object Cloning
Aviiiiii
UINT32Array
Comments
Confirm delete:
Do you really want to delete benchmark?