Skip to content

Instantly share code, notes, and snippets.

@mahadazad
Forked from jpoehls/main.js
Last active August 29, 2015 14:17
Show Gist options
  • Save mahadazad/24785ab441e7798f440c to your computer and use it in GitHub Desktop.
Save mahadazad/24785ab441e7798f440c to your computer and use it in GitHub Desktop.
var Benchmark = require('benchmark');
var request = require('request');
var suite = new Benchmark.Suite;
// add tests
suite.add('Calling cow api', {
defer: true,
fn: function(deferred) {
request({
url: 'http://cowsay.morecode.org/say',
method: 'POST',
form: { format: 'text', message: "Some message." }
}, function(error, response, body) {
deferred.resolve();
});
}
})
// add listeners
.on('cycle', function(event, bench) {
console.log(String(bench));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').pluck('name'));
})
// run async
.run({ 'async': true });
Calling cow api x 6.96 ops/sec ±27.82% (33 runs sampled)
Fastest is Calling cow api
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment