The following benchmark results are generated on a MacBook (Early 2016) with a 1,3 GHz Intel Core m7 processor using Node.js 10.8.0.
To run them your self, run:
npm run bench
See raw results in results.csv
Method | Features | Re-use | Sync | Cache | Format | Ops/sec | RME | Samples |
---|---|---|---|---|---|---|---|---|
uuid/v1 | π | β | uuid | 1,031,720 | Β±1.68% | 89 | ||
uuid/v1 | π | β | hex | 402,318 | Β±1.38% | 86 | ||
uuid/v1 | π | β | β | hex | 544,231 | Β±1.02% | 91 | |
uuid/v1 | π | β | buffer | 463,279 | Β±2.10% | 84 | ||
uuid/v1 | π | β | β | buffer | 625,377 | Β±1.61% | 91 | |
uuid/v4 | πππ‘οΈ | β | uuid | 242,402 | Β±1.77% | 88 | ||
uuid/v4 | πππ‘οΈ | β | hex | 224,290 | Β±3.78% | 81 | ||
uuid/v4 | πππ‘οΈ | β | β | hex | 261,648 | Β±3.28% | 87 | |
uuid/v4 | πππ‘οΈ | β | buffer | 248,587 | Β±5.01% | 79 | ||
uuid/v4 | πππ‘οΈ | β | β | buffer | 293,626 | Β±3.17% | 89 | |
fast-uuid | ππ | β | uuid | 647,364 | Β±0.82% | 91 | ||
uuid-random | πππ‘οΈ | β | 512 | uuid | 1,249,273 | Β±0.93% | 92 | |
uuid-random | πππ‘οΈ | β | 512 | hex | 1,182,259 | Β±0.92% | 92 | |
uuid-random | πππ‘οΈ | β | 512 | buffer | 1,749,568 | Β±0.94% | 91 | |
sodium-uuid | πππ‘οΈ | β | hex | 222,468 | Β±0.74% | 85 | ||
sodium-uuid | πππ‘οΈ | β | β | hex | 230,227 | Β±0.97% | 90 | |
sodium-uuid | πππ‘οΈ | β | buffer | 282,921 | Β±0.76% | 95 | ||
sodium-uuid | πππ‘οΈ | β | β | buffer | 285,123 | Β±0.79% | 91 | |
sodium-native | πππ‘οΈ | β | hex | 207,240 | Β±1.85% | 92 | ||
sodium-native | πππ‘οΈ | β | β | hex | 246,718 | Β±1.20% | 93 | |
sodium-native | πππ‘οΈ | β | buffer | 218,728 | Β±2.85% | 87 | ||
sodium-native | πππ‘οΈ | β | β | buffer | 288,010 | Β±0.76% | 95 | |
sodium-native | πππ‘οΈ | β | 256 | hex | 487,380 | Β±0.66% | 95 | |
sodium-native | πππ‘οΈ | β | β | 256 | hex | 484,132 | Β±0.69% | 89 |
sodium-native | πππ‘οΈ | β | 256 | buffer | 579,664 | Β±0.59% | 87 | |
sodium-native | πππ‘οΈ | β | β | 256 | buffer | 567,894 | Β±0.72% | 86 |
sodium-native | πππ‘οΈ | β | 4096 | hex | 509,949 | Β±4.29% | 85 | |
sodium-native | πππ‘οΈ | β | β | 4096 | hex | 514,632 | Β±0.95% | 92 |
sodium-native | πππ‘οΈ | β | 4096 | buffer | 589,869 | Β±0.83% | 91 | |
sodium-native | πππ‘οΈ | β | β | 4096 | buffer | 584,236 | Β±0.59% | 93 |
sodium-native | πππ‘οΈ | β | 65536 | hex | 549,442 | Β±0.98% | 27 | |
sodium-native | πππ‘οΈ | β | β | 65536 | hex | 503,349 | Β±0.76% | 81 |
sodium-native | πππ‘οΈ | β | 65536 | buffer | 592,077 | Β±1.12% | 87 | |
sodium-native | πππ‘οΈ | β | β | 65536 | buffer | 635,565 | Β±0.92% | 18 |
crypto.randomBytes | πππ‘οΈ | hex | 36,611 | Β±1.81% | 73 | |||
crypto.randomBytes | πππ‘οΈ | β | hex | 247,546 | Β±2.87% | 87 | ||
crypto.randomBytes | πππ‘οΈ | buffer | 38,647 | Β±1.39% | 76 | |||
crypto.randomBytes | πππ‘οΈ | β | buffer | 283,446 | Β±2.93% | 88 | ||
crypto.randomBytes | πππ‘οΈ | β | 256 | hex | 930,412 | Β±1.40% | 88 | |
crypto.randomBytes | πππ‘οΈ | β | β | 256 | hex | 893,849 | Β±1.18% | 91 |
crypto.randomBytes | πππ‘οΈ | 256 | hex | 322,917 | Β±1.66% | 76 | ||
crypto.randomBytes | πππ‘οΈ | β | 256 | hex | 319,095 | Β±1.52% | 74 | |
crypto.randomBytes | πππ‘οΈ | β | 256 | buffer | 1,263,214 | Β±1.34% | 85 | |
crypto.randomBytes | πππ‘οΈ | β | β | 256 | buffer | 1,210,984 | Β±2.24% | 85 |
crypto.randomBytes | πππ‘οΈ | 256 | buffer | 374,283 | Β±2.25% | 74 | ||
crypto.randomBytes | πππ‘οΈ | β | 256 | buffer | 385,773 | Β±1.32% | 72 | |
crypto.randomBytes | πππ‘οΈ | β | 4096 | hex | 1,213,789 | Β±0.61% | 94 | |
crypto.randomBytes | πππ‘οΈ | β | β | 4096 | hex | 1,132,888 | Β±1.04% | 90 |
crypto.randomBytes | πππ‘οΈ | 4096 | hex | 798,433 | Β±2.15% | 74 | ||
crypto.randomBytes | πππ‘οΈ | β | 4096 | hex | 803,000 | Β±1.31% | 78 | |
crypto.randomBytes | πππ‘οΈ | β | 4096 | buffer | 1,810,661 | Β±1.08% | 89 | |
crypto.randomBytes | πππ‘οΈ | β | β | 4096 | buffer | 1,708,659 | Β±1.13% | 93 |
crypto.randomBytes | πππ‘οΈ | 4096 | buffer | 1,179,573 | Β±1.65% | 73 | ||
crypto.randomBytes | πππ‘οΈ | β | 4096 | buffer | 1,084,560 | Β±1.86% | 74 | |
crypto.randomBytes | πππ‘οΈ | β | 65536 | hex | 1,238,794 | Β±0.67% | 90 | |
crypto.randomBytes | πππ‘οΈ | β | β | 65536 | hex | 1,162,037 | Β±0.68% | 91 |
crypto.randomBytes | πππ‘οΈ | 65536 | hex | 937,338 | Β±1.01% | 77 | ||
crypto.randomBytes | πππ‘οΈ | β | 65536 | hex | 910,588 | Β±1.20% | 75 | |
crypto.randomBytes | πππ‘οΈ | β | 65536 | buffer | 1,907,768 | Β±0.93% | 84 | |
crypto.randomBytes | πππ‘οΈ | β | β | 65536 | buffer | 1,789,604 | Β±0.58% | 90 |
crypto.randomBytes | πππ‘οΈ | 65536 | buffer | 1,359,017 | Β±1.67% | 75 | ||
crypto.randomBytes | πππ‘οΈ | β | 65536 | buffer | 1,349,288 | Β±1.19% | 77 | |
crypto.randomFillSync | πππ‘οΈ | β | β | hex | 297,034 | Β±3.03% | 91 | |
crypto.randomFillSync | πππ‘οΈ | β | β | buffer | 352,826 | Β±0.58% | 95 | |
crypto.randomFillSync | πππ‘οΈ | β | 256 | hex | 972,593 | Β±2.21% | 89 | |
crypto.randomFillSync | πππ‘οΈ | β | β | 256 | hex | 1,003,555 | Β±1.26% | 91 |
crypto.randomFillSync | πππ‘οΈ | β | 256 | buffer | 1,533,437 | Β±0.94% | 89 | |
crypto.randomFillSync | πππ‘οΈ | β | β | 256 | buffer | 1,498,401 | Β±0.83% | 89 |
crypto.randomFillSync | πππ‘οΈ | β | 4096 | hex | 1,299,413 | Β±1.33% | 92 | |
crypto.randomFillSync | πππ‘οΈ | β | β | 4096 | hex | 1,277,688 | Β±0.94% | 89 |
crypto.randomFillSync | πππ‘οΈ | β | 4096 | buffer | 2,127,692 | Β±1.18% | 90 | |
crypto.randomFillSync | πππ‘οΈ | β | β | 4096 | buffer | 2,030,611 | Β±0.78% | 95 |
crypto.randomFillSync | πππ‘οΈ | β | 65536 | hex | 1,411,415 | Β±0.73% | 61 | |
crypto.randomFillSync | πππ‘οΈ | β | β | 65536 | hex | 1,351,733 | Β±1.12% | 64 |
crypto.randomFillSync | πππ‘οΈ | β | 65536 | buffer | 2,173,932 | Β±0.94% | 91 | |
crypto.randomFillSync | πππ‘οΈ | β | β | 65536 | buffer | 1,978,253 | Β±1.79% | 89 |
crypto.randomFill | πππ‘οΈ | β | hex | 35,753 | Β±1.64% | 74 | ||
crypto.randomFill | πππ‘οΈ | β | buffer | 40,443 | Β±1.72% | 76 | ||
crypto.randomFill | πππ‘οΈ | 256 | hex | 337,253 | Β±1.89% | 69 | ||
crypto.randomFill | πππ‘οΈ | β | 256 | hex | 342,601 | Β±1.53% | 74 | |
crypto.randomFill | πππ‘οΈ | 256 | buffer | 394,036 | Β±1.80% | 73 | ||
crypto.randomFill | πππ‘οΈ | β | 256 | buffer | 398,759 | Β±1.55% | 73 | |
crypto.randomFill | πππ‘οΈ | 4096 | hex | 838,637 | Β±1.58% | 75 | ||
crypto.randomFill | πππ‘οΈ | β | 4096 | hex | 795,834 | Β±1.19% | 77 | |
crypto.randomFill | πππ‘οΈ | 4096 | buffer | 1,099,979 | Β±4.33% | 73 | ||
crypto.randomFill | πππ‘οΈ | β | 4096 | buffer | 1,124,590 | Β±1.94% | 72 | |
crypto.randomFill | πππ‘οΈ | 65536 | hex | 910,602 | Β±1.70% | 77 | ||
crypto.randomFill | πππ‘οΈ | β | 65536 | hex | 899,567 | Β±1.12% | 78 | |
crypto.randomFill | πππ‘οΈ | 65536 | buffer | 1,379,134 | Β±1.24% | 77 | ||
crypto.randomFill | πππ‘οΈ | β | 65536 | buffer | 1,356,052 | Β±1.10% | 74 | |
/dev/random | πππ‘οΈ | β | hex | 40,092 | Β±1.67% | 73 | ||
/dev/random | πππ‘οΈ | β | β | hex | 226,814 | Β±0.46% | 96 | |
/dev/random | πππ‘οΈ | β | buffer | 41,103 | Β±2.07% | 76 | ||
/dev/random | πππ‘οΈ | β | β | buffer | 262,087 | Β±0.66% | 93 | |
/dev/random | πππ‘οΈ | 256 | hex | 234,066 | Β±1.29% | 77 | ||
/dev/random | πππ‘οΈ | β | 256 | hex | 235,687 | Β±1.66% | 75 | |
/dev/random | πππ‘οΈ | β | β | 256 | hex | 443,135 | Β±0.88% | 88 |
/dev/random | πππ‘οΈ | 256 | buffer | 269,161 | Β±1.50% | 72 | ||
/dev/random | πππ‘οΈ | β | 256 | buffer | 267,478 | Β±1.62% | 72 | |
/dev/random | πππ‘οΈ | β | β | 256 | buffer | 525,963 | Β±0.59% | 92 |
/dev/random | πππ‘οΈ | 4096 | hex | 381,099 | Β±1.53% | 77 | ||
/dev/random | πππ‘οΈ | β | 4096 | hex | 388,474 | Β±1.50% | 77 | |
/dev/random | πππ‘οΈ | β | β | 4096 | hex | 491,756 | Β±0.60% | 93 |
/dev/random | πππ‘οΈ | 4096 | buffer | 454,175 | Β±1.28% | 76 | ||
/dev/random | πππ‘οΈ | β | 4096 | buffer | 448,020 | Β±1.31% | 77 | |
/dev/random | πππ‘οΈ | β | β | 4096 | buffer | 574,020 | Β±0.64% | 94 |
/dev/random | πππ‘οΈ | 65536 | hex | 409,728 | Β±1.48% | 75 | ||
/dev/random | πππ‘οΈ | β | 65536 | hex | 450,289 | Β±1.31% | 50 | |
/dev/random | πππ‘οΈ | β | β | 65536 | hex | 541,220 | Β±1.04% | 31 |
/dev/random | πππ‘οΈ | 65536 | buffer | 483,239 | Β±1.34% | 74 | ||
/dev/random | πππ‘οΈ | β | 65536 | buffer | 525,563 | Β±1.42% | 49 | |
/dev/random | πππ‘οΈ | β | β | 65536 | buffer | 636,141 | Β±0.76% | 19 |
/dev/urandom | ππ | β | hex | 39,507 | Β±1.28% | 76 | ||
/dev/urandom | ππ | β | β | hex | 225,501 | Β±1.16% | 96 | |
/dev/urandom | ππ | β | buffer | 42,675 | Β±1.60% | 75 | ||
/dev/urandom | ππ | β | β | buffer | 262,925 | Β±0.53% | 96 | |
/dev/urandom | ππ | 256 | hex | 242,490 | Β±1.25% | 76 | ||
/dev/urandom | ππ | β | 256 | hex | 247,783 | Β±1.28% | 74 | |
/dev/urandom | ππ | β | β | 256 | hex | 449,219 | Β±0.57% | 95 |
/dev/urandom | ππ | 256 | buffer | 260,615 | Β±1.44% | 73 | ||
/dev/urandom | ππ | β | 256 | buffer | 268,182 | Β±1.63% | 74 | |
/dev/urandom | ππ | β | β | 256 | buffer | 529,952 | Β±0.34% | 91 |
/dev/urandom | ππ | 4096 | hex | 393,407 | Β±1.38% | 73 | ||
/dev/urandom | ππ | β | 4096 | hex | 386,528 | Β±1.07% | 78 | |
/dev/urandom | ππ | β | β | 4096 | hex | 489,407 | Β±0.71% | 92 |
/dev/urandom | ππ | 4096 | buffer | 450,002 | Β±1.35% | 73 | ||
/dev/urandom | ππ | β | 4096 | buffer | 446,349 | Β±1.50% | 78 | |
/dev/urandom | ππ | β | β | 4096 | buffer | 573,550 | Β±0.72% | 91 |
/dev/urandom | ππ | 65536 | hex | 416,024 | Β±1.48% | 76 | ||
/dev/urandom | ππ | β | 65536 | hex | 445,563 | Β±1.30% | 51 | |
/dev/urandom | ππ | β | β | 65536 | hex | 539,710 | Β±0.82% | 32 |
/dev/urandom | ππ | 65536 | buffer | 492,679 | Β±1.67% | 71 | ||
/dev/urandom | ππ | β | 65536 | buffer | 479,059 | Β±1.36% | 74 | |
/dev/urandom | ππ | β | β | 65536 | buffer | 637,976 | Β±0.65% | 20 |
The following ID generators does not generate 128 bit id's. Beware that not all of them are globally unique.
Method | Features | Re-use | Sync | Cache | Ops/sec | RME | Samples | Example |
---|---|---|---|---|---|---|---|---|
hyperid cold start | π | β | 102,478 | Β±1.01% | 89 | PK9867v+RGmX2kdtHbPe1g/0 | ||
hyperid normal | π | β | 8,495,558 | Β±2.28% | 83 | PK9867v+RGmX2kdtHbPe1g/0 | ||
cuid | π | β | 448,945 | Β±0.66% | 88 | cjksp2h270000e8hgvs5t9ihj | ||
shortid | π | β | 22,552 | Β±3.58% | 81 | p300jY3TE | ||
nanoid | πππ‘οΈ | β | 237,373 | Β±1.36% | 86 | 2nlN~BJaTgdWQm01WS2uG |
- Method: Name of npm module, Node.js core function, or OS based random generator used
- Features:
- π (GUID) - The ID is globally unique
- π‘ (Secure) - The method used to generate the ID doesn't leak metadata and it's not possible to predict what the next ID will be
- π (Random) - The ID is made up of random data
- Re-use: An output buffer was re-used between each test to potentially reduce the number of objects that needed to be allocated
- Sync: The ID generation was performed synchronously
- Cache:
- <empty> - Only the amount of bytes required to generate a 128 bit number was read into memory
- <Number> - Number of bytes read into memory the first time a 128 bit number was requested. Subsequent runs would use the leftover bytes in the cache until it had been depleted, at which time another chunk of bytes would be read into memory
- Format:
uuid
- ID is a UUID formatted string representing a 128 bit number, e.g.3a017fc5-4f50-4db9-b0ce-4547ba0a1bfd
hex
- ID is a hex formatted string representing a 128 bit number, e.g.3a017fc54f504db9b0ce4547ba0a1bfd
buffer
- ID is a raw 128 bit binary Buffer objectother
- ID is not a UUID or 128 bit number, and might not be globally unique
- Ops/sec: Number of ID's generated per second
- RME: The relative margin of error (expressed as a percentage of the mean)
- Samples: Number of runs sampled
- Example: Example of a generated ID