Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/uuid-random/benchmark/ drwxr-xr-x | |
| Viewing file: Select action/file-type: /**
*
* Benchmark UUID libraries
*
* Libraries no longer included:
* - an-uuid (no longer exists?)
* - node-uuid (deprecated)
* - performance-uuid (doesn't work anymore?)
* - simply-uuid (extremely slow)
* - fast-uuid (no crypto PRNG option)
*
*/
var Stats = require('fast-stats').Stats
var microtime = require('microtime')
var id128 = require('id128')
var libs = {
// This lib (fastest)
'uuid-random': require('..'),
// Really extensive uuid lib
id128: () => id128.Uuid4.generate().toCanonical(),
// Slightly slower.
'portable-uuid': require('portable-uuid'),
// Best npm package name
uuid: require('uuid').v4,
// Modern non-RFC uuid
nanoid: require('nanoid').nanoid,
}
var i,
start,
seconds,
ops = 1000000,
runs = 10
function percent(n) {
return Math.round(n * 100 * 100) / 100
}
for (const lib in libs) {
const results = new Stats()
for (let run = 0; run < runs; run++) {
start = microtime.now()
for (i = 0; i < ops; i++) libs[lib]()
seconds = (microtime.now() - start) / 1000000
results.push(ops / seconds)
}
const amean = results.amean()
const moe = percent(results.moe() / amean)
console.log(`${lib} x ${amean.toLocaleString()} ops/sec ±${moe}%`)
}
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0243 ]-- |