Skip to content

Instantly share code, notes, and snippets.

@KurtPreston
Created January 8, 2020 23:01
Show Gist options
  • Save KurtPreston/ff7e69444a05a75d0b42cb1422503206 to your computer and use it in GitHub Desktop.
Save KurtPreston/ff7e69444a05a75d0b42cb1422503206 to your computer and use it in GitHub Desktop.
import * as hashIt from 'hash-it';
import * as hashSum from 'hash-sum';
import {forEach, times} from 'lodash';
import * as objectHash from 'object-hash';
import {CompiledJsonSchemas} from 'salsa/schemas';
import {performance} from 'salsa/utils/performance';
describe('hash', () => {
const libs = [{
name: 'objectHash',
fn: objectHash
}, {
name: 'hash-sum',
fn: hashSum
}, {
name: 'hash-it',
fn: hashIt.default
}];
fit('compare', () => {
libs.forEach(({name, fn}) => {
const start = performance.now();
times(100, () => {
forEach(CompiledJsonSchemas, (schema) => {
fn(schema);
});
});
const duration = performance.now() - start;
console.log(`${name}: ${duration}`);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment