Skip to content

Instantly share code, notes, and snippets.

@Lokua
Created April 19, 2017 02:32
Show Gist options
  • Save Lokua/c741a21af52c40d1409ead1bb6a27ca6 to your computer and use it in GitHub Desktop.
Save Lokua/c741a21af52c40d1409ead1bb6a27ca6 to your computer and use it in GitHub Desktop.
quick benchmark.js
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