-
-
Save mahadazad/24785ab441e7798f440c 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
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 }); |
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
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