Skip to content

Commit

Permalink
add benchmark for the urlSafe instance too (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
capaj authored Jun 5, 2020
1 parent 0aa2df4 commit e6704e5
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ const benchmark = require('benchmark')
const Hashids = require('hashids')
const shortid = require('shortid')
const nid = require('nid')
const crypto = require('crypto')
const uuid = require('uuid')
const hyperid = require('.')()
const hyperid = require('.')

const hyperIdSafeUrlInstance = hyperid({
urlSafe: true
})
const hyperIdInstance = hyperid()

const suite = new benchmark.Suite()

Expand All @@ -25,6 +31,10 @@ suite.add('shortid', function () {
shortid()
})

suite.add('crypto.random', function () {
crypto.randomBytes(33).toString('hex')
})

suite.add('nid', function () {
nid()
})
Expand All @@ -38,11 +48,14 @@ suite.add('uuid.v1', function () {
})

suite.add('hyperid - variable length', function () {
hyperid()
hyperIdInstance()
})

suite.add('hyperid - fixed length', function () {
hyperid(true)
hyperIdInstance(true)
})
suite.add('hyperid - fixed length, url safe', function () {
hyperIdSafeUrlInstance(true)
})

suite.on('cycle', cycle)
Expand Down

0 comments on commit e6704e5

Please sign in to comment.