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