Merge pull request #71 from jerome-benoit/dependabot/npm_and_yarn/eslint-plugin-n...
[benchmarks-js.git] / uuid-generator.mjs
1 import crypto from 'node:crypto'
2 import Benchmark from 'benny'
3 import { v4 as uuid } from '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 ).catch(err => {
31 console.error(err)
32 })