Permalink
Browse files

bench: Use siege instead of ab

Getting pretty tired of obscure apr errors.
  • Loading branch information...
1 parent 25fe696 commit 9b12e5e4ff5f912deffa69a14a5558d55ca06465 @isaacs committed Feb 13, 2013
Showing with 20 additions and 19 deletions.
  1. +16 −9 benchmark/common.js
  2. +2 −2 benchmark/http/cluster.js
  3. +2 −8 benchmark/http/http_simple.js
View
@@ -60,35 +60,42 @@ function Benchmark(fn, options) {
}
// run ab against a server.
-Benchmark.prototype.ab = function(path, args, cb) {
+Benchmark.prototype.siege = function(path, args, cb) {
var url = 'http://127.0.0.1:' + exports.PORT + path;
- args.push(url);
var self = this;
var out = '';
var spawn = require('child_process').spawn;
- // console.error('ab %s', args.join(' '));
- var child = spawn('ab', args);
+ // console.error('siege %s', args.join(' '));
+ var child = spawn('siege', args.concat(['-b', '-q', url]));
child.stdout.setEncoding('utf8');
child.stdout.on('data', function(chunk) {
out += chunk;
});
+ child.stderr.setEncoding('utf8');
+ var err = '';
+ child.stderr.on('data', function(chunk) {
+ err += chunk;
+ });
+
child.on('close', function(code) {
if (cb)
cb(code);
if (code) {
- console.error('ab failed with ' + code);
- process.exit(code)
+ console.error('siege failed with ' + code);
+ console.error(err);
+ console.error(out);
+ process.exit(code);
}
- var m = out.match(/Requests per second: +([0-9\.]+)/);
+ var m = err.match(/Transaction rate:[ \t]+([0-9\.]+)/);
var qps = m && +m[1];
if (!qps) {
- process.stderr.write(out + '\n');
- console.error('ab produced strange output');
+ console.error('%j', err);
+ console.error('siege produced strange output');
process.exit(1);
}
self.report(+qps);
@@ -26,9 +26,9 @@ function main(conf) {
setTimeout(function() {
var path = '/' + conf.type + '/' + conf.length;
- var args = ['-r', '-t', 5, '-c', conf.c, '-k'];
+ var args = ['-t', '5S', '-c', conf.c];
- bench.ab(path, args, function() {
+ bench.siege(path, args, function() {
w1.destroy();
w2.destroy();
});
@@ -2,7 +2,6 @@ var common = require('../common.js');
var PORT = common.PORT;
var bench = common.createBenchmark(main, {
- // unicode confuses ab on os x.
type: ['bytes', 'buffer'],
length: [4, 1024, 102400],
c: [50, 150]
@@ -15,14 +14,9 @@ function main(conf) {
var server = spawn(process.execPath, [simple]);
setTimeout(function() {
var path = '/' + conf.type + '/' + conf.length; //+ '/' + conf.chunks;
- var args = ['-r', '-t', 5];
+ var args = ['-t', '5S', '-c', conf.c];
- if (+conf.c !== 1)
- args.push('-c', conf.c);
-
- args.push('-k');
-
- bench.ab(path, args, function() {
+ bench.siege(path, args, function() {
server.kill();
});
}, 2000);

0 comments on commit 9b12e5e

Please sign in to comment.