Created
January 8, 2020 23:01
-
-
Save KurtPreston/ff7e69444a05a75d0b42cb1422503206 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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