build(deps-dev): apply updates
[benchmarks-js.git] / object-hash.mjs
CommitLineData
bf2f087f
JB
1import hashObject from 'hash-object'
2import { hasher } from 'node-object-hash'
3import hash from 'object-hash'
4import { bench, group, run } from 'tatami-ng'
5
6import { generateRandomObject } from './benchmark-utils.mjs'
7
8const object = generateRandomObject()
9
10group(`Hash object with ${Object.keys(object).length} keys`, () => {
11 bench('hash-object', (obj = object) => {
12 return hashObject(obj, { algorithm: 'sha256' })
13 })
14 bench('node-object-hash', (obj = object) => {
15 return hasher({ alg: 'sha256' }).hash(obj)
16 })
17 bench('object-hash', (obj = object) => {
18 return hash(obj, { algorithm: 'sha256' })
19 })
20})
21
22await run({
ebf80fe4 23 units: true,
bf2f087f 24})