| 1 | const crypto = require('crypto') |
| 2 | const Benchmark = require('benny') |
| 3 | const { v4: uuid } = require('uuid') |
| 4 | |
| 5 | Benchmark.suite( |
| 6 | 'UUIDv4 generator', |
| 7 | Benchmark.add('crypto randomUUID', () => { |
| 8 | crypto.randomUUID() |
| 9 | }), |
| 10 | Benchmark.add('uuid', () => { |
| 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 | }) |
| 30 | ) |