https://github.com/2fd/benchmark-uuid
https://github.com/2fd/benchmark-uuid
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/2fd/benchmark-uuid
- Owner: 2fd
- License: mit
- Created: 2023-08-21T21:15:36.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-09-20T15:08:41.000Z (over 2 years ago)
- Last Synced: 2025-03-13T07:13:45.167Z (over 1 year ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# benchmark-uuid
[](https://github.com/2fd/benchmark-uuid/actions/workflows/benchmark.yml)
This benchmark is used to compare the performance of different UUID v4 implementations in NodeJS.
- [`node node.js`](./node.js)
- [`node browser.js`](./browser.js)
- [`node uuid3.js`](./uuid3.js)
- [`node uuid7.js`](./uuid7.js)
- [`node uuid8.js`](./uuid8.js)
- [`node uuid9.js`](./uuid9.j)
## Usage
```sh
npm start
```
## Results
NodeJS implementation (`import { randomUUID } from 'crypto'`), Web implementation (`crypto.randomUUID`) and uuid@9 (`import { v4 } from 'uuid'`) are indistinguishable in performance, while uuid@8 is 10x slower and uuid@7 and uuid@3 are 40x slower.
### Node 16
```txt
'node node.js' ran
1.02 ± 0.05 times faster than 'node browser.js'
1.03 ± 0.04 times faster than 'node uuid9.js'
10.10 ± 0.38 times faster than 'node uuid8.js'
43.10 ± 1.73 times faster than 'node uuid7.js'
43.27 ± 1.70 times faster than 'node uuid3.js'
```
### Node 18
```txt
'node browser.js' ran
1.01 ± 0.01 times faster than 'node node.js'
1.04 ± 0.01 times faster than 'node uuid9.js'
9.07 ± 0.17 times faster than 'node uuid8.js'
36.48 ± 0.31 times faster than 'node uuid3.js'
36.56 ± 0.42 times faster than 'node uuid7.js'
```
### Node 20
```txt
'node browser.js' ran
1.00 ± 0.01 times faster than 'node node.js'
1.03 ± 0.01 times faster than 'node uuid9.js'
12.30 ± 0.10 times faster than 'node uuid8.js'
52.17 ± 0.72 times faster than 'node uuid3.js'
52.75 ± 0.79 times faster than 'node uuid7.js'
```