X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=object-hash.mjs;fp=object-hash.mjs;h=d20a317e311e3cbf7607f57ae4a43f63aebbeec1;hb=bf2f087f3d30a4d8437a38b77cd0ae6f6f7da830;hp=0000000000000000000000000000000000000000;hpb=9fe780df3b1ec373b4fd145fad258a899320d9ac;p=benchmarks-js.git diff --git a/object-hash.mjs b/object-hash.mjs new file mode 100644 index 0000000..d20a317 --- /dev/null +++ b/object-hash.mjs @@ -0,0 +1,24 @@ +import hashObject from 'hash-object' +import { hasher } from 'node-object-hash' +import hash from 'object-hash' +import { bench, group, run } from 'tatami-ng' + +import { generateRandomObject } from './benchmark-utils.mjs' + +const object = generateRandomObject() + +group(`Hash object with ${Object.keys(object).length} keys`, () => { + bench('hash-object', (obj = object) => { + return hashObject(obj, { algorithm: 'sha256' }) + }) + bench('node-object-hash', (obj = object) => { + return hasher({ alg: 'sha256' }).hash(obj) + }) + bench('object-hash', (obj = object) => { + return hash(obj, { algorithm: 'sha256' }) + }) +}) + +await run({ + units: true +})