New benchmarking without any library to better understand how the bench is executed...
[poolifier.git] / benchmarks / idgen.js
1 const uuidv1 = require('uuid/v1')
2 const uuidv4 = require('uuid/v4')
3 const uuidv5 = require('uuid/v5')
4 const Benchmark = require('benchmark')
5 const suite = new Benchmark.Suite()
6 const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341'
7
8 // add tests
9 suite.add('uuid v4', function () {
10 uuidv4()
11 })
12 .add('uuid v5', function () {
13 uuidv5('Hello, World!', MY_NAMESPACE)
14 })
15 .add('uuid v1', async function () {
16 uuidv1()
17 })
18 // add listeners
19 .on('cycle', function (event) {
20 console.log(String(event.target))
21 })
22 .on('complete', function () {
23 this.filter('fastest').map('name')
24 console.log('Fastest is ' + this.filter('fastest').map('name'))
25 })
26 // run async
27 .run({ async: true })