mirror: A fast canonicalisation utility for stable object equality
0

Configure Feed

Select the types of activity you want to include in your feed.

chore: adds `json-stable-stringify` to benchmark

Marais Rossouw (Oct 12, 2023, 1:40 PM +1000) dee9f398 79b27862

+33 -19
+5 -3
bench/index.js
··· 3 3 import { createHash } from 'crypto'; 4 4 import objectHash from 'object-hash'; 5 5 import { identify } from 'object-identity'; 6 + import jsonStableStringify from 'json-stable-stringify'; 6 7 7 8 const getObject = () => { 8 9 const c = [1]; ··· 25 26 26 27 return (o) => objectHash(o, options); 27 28 }, 28 - 29 + 'json-stable-stringify'() { 30 + return (o) => jsonStableStringify(o); 31 + }, 29 32 ['object-identity :: hashed']() { 30 - const hasher = (val) => 31 - createHash('sha1').update(val).digest('hex'); 33 + const hasher = (val) => createHash('sha1').update(val).digest('hex'); 32 34 33 35 return (o) => identify(o, hasher); 34 36 },
+1
bench/package.json
··· 2 2 "type": "module", 3 3 "dependencies": { 4 4 "@marais/bench": "0.0.8", 5 + "json-stable-stringify": "^1.0.2", 5 6 "object-hash": "^3.0.0", 6 7 "object-identity": "file:.." 7 8 }
+22 -12
bench/pnpm-lock.yaml
··· 8 8 '@marais/bench': 9 9 specifier: 0.0.8 10 10 version: 0.0.8 11 + json-stable-stringify: 12 + specifier: ^1.0.2 13 + version: 1.0.2 11 14 object-hash: 12 15 specifier: ^3.0.0 13 16 version: 3.0.0 ··· 16 19 version: file:.. 17 20 18 21 packages: 22 + 19 23 /@marais/bench@0.0.8: 20 - resolution: 21 - { integrity: sha512-DZ3TqK1eUN77E2nV2Aj2aady61rveJGqGAPNQglzoJL001HJq9elFLRS6pw25e6geIEmRld9cJ5F/EHFUYa+DQ== } 24 + resolution: {integrity: sha512-DZ3TqK1eUN77E2nV2Aj2aady61rveJGqGAPNQglzoJL001HJq9elFLRS6pw25e6geIEmRld9cJ5F/EHFUYa+DQ==} 22 25 dependencies: 23 26 '@thi.ng/bench': 3.4.0 24 27 dev: false 25 28 26 29 /@thi.ng/api@8.8.2: 27 - resolution: 28 - { integrity: sha512-kJCBKhHEYv/gSnbrCGnEgoAX/9bRmVSttQ0GVqQIdJlW3IFlgtz3kz357zcYNQ8mB6cY87e0XxJY3VdbYsgiyQ== } 29 - engines: { node: '>=12.7' } 30 + resolution: {integrity: sha512-kJCBKhHEYv/gSnbrCGnEgoAX/9bRmVSttQ0GVqQIdJlW3IFlgtz3kz357zcYNQ8mB6cY87e0XxJY3VdbYsgiyQ==} 31 + engines: {node: '>=12.7'} 30 32 dev: false 31 33 32 34 /@thi.ng/bench@3.4.0: 33 - resolution: 34 - { integrity: sha512-eY28lsU/7mxV2KrPebo5DTKMDslWDNTcKNNomNcJMKfdDSPmb5Mb7InqekPuv8K2iAC1EVghFBHCi/lIO22qFg== } 35 - engines: { node: '>=12.7' } 35 + resolution: {integrity: sha512-eY28lsU/7mxV2KrPebo5DTKMDslWDNTcKNNomNcJMKfdDSPmb5Mb7InqekPuv8K2iAC1EVghFBHCi/lIO22qFg==} 36 + engines: {node: '>=12.7'} 36 37 dependencies: 37 38 '@thi.ng/api': 8.8.2 38 39 dev: false 39 40 41 + /json-stable-stringify@1.0.2: 42 + resolution: {integrity: sha512-eunSSaEnxV12z+Z73y/j5N37/In40GK4GmsSy+tEHJMxknvqnA7/djeYtAgW0GsWHUfg+847WJjKaEylk2y09g==} 43 + dependencies: 44 + jsonify: 0.0.1 45 + dev: false 46 + 47 + /jsonify@0.0.1: 48 + resolution: {integrity: sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==} 49 + dev: false 50 + 40 51 /object-hash@3.0.0: 41 - resolution: 42 - { integrity: sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw== } 43 - engines: { node: '>= 6' } 52 + resolution: {integrity: sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==} 53 + engines: {node: '>= 6'} 44 54 dev: false 45 55 46 56 file:..: 47 - resolution: { directory: .., type: directory } 57 + resolution: {directory: .., type: directory} 48 58 name: object-identity 49 59 dev: false
+5 -4
readme.md
··· 58 58 > via the [`/bench`](/bench) directory with Node v18.16.1 (Apple M1 Pro) 59 59 60 60 ``` 61 - ✔ object-identity ~ 53,216,325 ops/sec ± 0.34% 62 - ✔ object-hash ~ 110,440 ops/sec ± 0.01% 63 - ✔ object-identity :: hashed ~ 45,415,100 ops/sec ± 0.05% 64 - ✔ object-hash :: hashed ~ 51,365 ops/sec ± 0.01% 61 + ✔ object-identity ~ 55,101,604 ops/sec ± 0.16% 62 + ✔ object-hash ~ 103,820 ops/sec ± 0.01% 63 + ✔ json-stable-stringify ~ 608,119 ops/sec ± 0.01% 64 + ✔ object-identity :: hashed ~ 46,650,067 ops/sec ± 0.05% 65 + ✔ object-hash :: hashed ~ 50,966 ops/sec ± 0.01% 65 66 ``` 66 67 67 68 > ^ `object-identity` is not as feature-full it's alternatives, specifically around `function` values and other node