Skip to content

Commit

Permalink
Benchmark with arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
skomski committed Apr 7, 2012
1 parent 2cfccfe commit af5425e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions benchmark/simple.js
Expand Up @@ -3,11 +3,13 @@ var fs = require('fs')
var curl = require('..')
var http = require('http')

var processArguments = process.argv.splice(2);

var suite = new Benchmark.Suite();

suite.add('http', function(deferred) {
var options = {
host: 'twitter.com',
host: processArguments[0],
port: 80
};

Expand All @@ -17,16 +19,16 @@ suite.add('http', function(deferred) {
res.on('data', function(buffer) {
data += buffer;
});
res.on('end', function (chunk) {
res.on('end', function () {
deferred.resolve();
});
});
req.end();
}, { defer: true, minSamples: 50, maxTime: 30 });
}, { defer: true, minSamples: 50, maxTime: 10 });

suite.add('curl', function(deferred) {
var request = curl.createRequest();
request.setOption('url', 'http://twitter.com');
request.setOption('url', 'http://' + processArguments[0]);
var data = '';
request.on('data', function(buffer) {
data += buffer;
Expand All @@ -35,7 +37,7 @@ suite.add('curl', function(deferred) {
deferred.resolve();
});
request.execute();
},{ defer: true, minSamples: 50, maxTime: 30 });
},{ defer: true, minSamples: 50, maxTime: 10 });

suite.on('cycle', function(event, bench) {
console.log(String(bench));
Expand Down

0 comments on commit af5425e

Please sign in to comment.