Commit | Line | Data |
---|---|---|
5ae4976a JB |
1 | const Benchmark = require('benny') |
2 | const crypto = require('crypto') | |
3 | const { v4: uuidv4 } = require('uuid') | |
4 | const { uuid } = require('uuidv4') | |
5 | ||
6 | Benchmark.suite( | |
7 | 'UUIDv4 generator', | |
8 | Benchmark.add('crypto randomUUID', () => { | |
9 | crypto.randomUUID() | |
10 | }), | |
11 | Benchmark.add('uuid', () => { | |
12 | uuidv4() | |
13 | }), | |
14 | Benchmark.add('uuidv4', () => { | |
15 | uuid() | |
16 | }), | |
17 | Benchmark.cycle(), | |
18 | Benchmark.complete(), | |
19 | Benchmark.save({ | |
20 | file: 'uuid-generator', | |
21 | format: 'json', | |
22 | details: true | |
23 | }), | |
24 | Benchmark.save({ | |
25 | file: 'uuid-generator', | |
26 | format: 'chart.html', | |
27 | details: true | |
28 | }), | |
29 | Benchmark.save({ | |
30 | file: 'uuid-generator', | |
31 | format: 'table.html', | |
32 | details: true | |
33 | }) | |
34 | ) |