Created
April 19, 2017 02:32
-
-
Save Lokua/c741a21af52c40d1409ead1bb6a27ca6 to your computer and use it in GitHub Desktop.
quick benchmark.js
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
const { Suite } = require('benchmark') | |
const test = (specs = {/*name:fn*/}) => { | |
const suite = new Suite() | |
Object.keys(specs).forEach(name => suite.add(name, specs[name])) | |
suite.on('cycle', e => console.info(String(e.target))) | |
suite.on('complete', () => console.info(`Fastest is ${suite.filter('fastest').map('name')}`)) | |
suite.run({ async: false }) | |
} | |
// // EXAMPLE: | |
// test({ | |
// 'thing 1': () => {}, | |
// 'thing 2': () => {} | |
// }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment