Skip to content

Instantly share code, notes, and snippets.

@rms1000watt
Created March 29, 2023 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rms1000watt/a93f6509b034537af9fc8f41c6a461e6 to your computer and use it in GitHub Desktop.
Save rms1000watt/a93f6509b034537af9fc8f41c6a461e6 to your computer and use it in GitHub Desktop.
benchmark in nodejs
const Benchmark = require('benchmark');
suite
.add('test1', function() {
console.log('stuff');
})
.add('test2', function() {
console.log('stuff');
})
.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').map('name'));
})
.run({ 'async': true });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment