bench: Use wrk for http benchmarking
Remove ab, since it's no longer used.
This commit is contained in:
parent
e850cbab1c
commit
ef08f0fbb1
6
Makefile
6
Makefile
@ -313,6 +313,10 @@ dist-upload: $(TARBALL) $(PKG)
|
|||||||
scp $(TARBALL) node@nodejs.org:~/web/nodejs.org/dist/$(VERSION)/$(TARBALL)
|
scp $(TARBALL) node@nodejs.org:~/web/nodejs.org/dist/$(VERSION)/$(TARBALL)
|
||||||
scp $(PKG) node@nodejs.org:~/web/nodejs.org/dist/$(VERSION)/$(TARNAME).pkg
|
scp $(PKG) node@nodejs.org:~/web/nodejs.org/dist/$(VERSION)/$(TARNAME).pkg
|
||||||
|
|
||||||
|
wrkclean:
|
||||||
|
$(MAKE) -C tools/wrk/ clean
|
||||||
|
rm tools/wrk/wrk
|
||||||
|
|
||||||
wrk: tools/wrk/wrk
|
wrk: tools/wrk/wrk
|
||||||
tools/wrk/wrk:
|
tools/wrk/wrk:
|
||||||
$(MAKE) -C tools/wrk/
|
$(MAKE) -C tools/wrk/
|
||||||
@ -323,7 +327,7 @@ bench-net: all
|
|||||||
bench-tls: all
|
bench-tls: all
|
||||||
@$(NODE) benchmark/common.js tls
|
@$(NODE) benchmark/common.js tls
|
||||||
|
|
||||||
bench-http: all
|
bench-http: wrk all
|
||||||
@$(NODE) benchmark/common.js http
|
@$(NODE) benchmark/common.js http
|
||||||
|
|
||||||
bench-fs: all
|
bench-fs: all
|
||||||
|
@ -11,7 +11,6 @@ if (module === require.main) {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = require('path');
|
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var dir = path.join(__dirname, type);
|
var dir = path.join(__dirname, type);
|
||||||
var tests = fs.readdirSync(dir);
|
var tests = fs.readdirSync(dir);
|
||||||
@ -59,16 +58,18 @@ function Benchmark(fn, options) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// run ab against a server.
|
// benchmark an http server.
|
||||||
Benchmark.prototype.ab = function(path, args, cb) {
|
Benchmark.prototype.http = function(p, args, cb) {
|
||||||
var url = 'http://127.0.0.1:' + exports.PORT + path;
|
|
||||||
args.push(url);
|
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var out = '';
|
var wrk = path.resolve(__dirname, '..', 'tools', 'wrk', 'wrk');
|
||||||
|
var regexp = /Requests\/sec:[ \t]+([0-9\.]+)/;
|
||||||
var spawn = require('child_process').spawn;
|
var spawn = require('child_process').spawn;
|
||||||
// console.error('ab %s', args.join(' '));
|
var url = 'http://127.0.0.1:' + exports.PORT + p;
|
||||||
var child = spawn('ab', args);
|
|
||||||
|
args = args.concat(url);
|
||||||
|
|
||||||
|
var out = '';
|
||||||
|
var child = spawn(wrk, args);
|
||||||
|
|
||||||
child.stdout.setEncoding('utf8');
|
child.stdout.setEncoding('utf8');
|
||||||
|
|
||||||
@ -81,14 +82,14 @@ Benchmark.prototype.ab = function(path, args, cb) {
|
|||||||
cb(code);
|
cb(code);
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
console.error('ab failed with ' + code);
|
console.error('wrk failed with ' + code);
|
||||||
process.exit(code)
|
process.exit(code)
|
||||||
}
|
}
|
||||||
var m = out.match(/Requests per second: +([0-9\.]+)/);
|
var m = out.match(regexp);
|
||||||
var qps = m && +m[1];
|
var qps = m && +m[1];
|
||||||
if (!qps) {
|
if (!qps) {
|
||||||
process.stderr.write(out + '\n');
|
console.error('%j', out);
|
||||||
console.error('ab produced strange output');
|
console.error('wrk produced strange output');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
self.report(+qps);
|
self.report(+qps);
|
||||||
|
@ -7,7 +7,7 @@ if (cluster.isMaster) {
|
|||||||
// unicode confuses ab on os x.
|
// unicode confuses ab on os x.
|
||||||
type: ['bytes', 'buffer'],
|
type: ['bytes', 'buffer'],
|
||||||
length: [4, 1024, 102400],
|
length: [4, 1024, 102400],
|
||||||
c: [50, 150]
|
c: [50, 500]
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
require('../http_simple.js');
|
require('../http_simple.js');
|
||||||
@ -27,11 +27,12 @@ function main(conf) {
|
|||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var path = '/' + conf.type + '/' + conf.length;
|
var path = '/' + conf.type + '/' + conf.length;
|
||||||
var args = ['-r', '-t', 5, '-c', conf.c, '-k'];
|
var args = ['-r', '-t', 5, '-c', conf.c, '-k'];
|
||||||
|
var args = ['-r', 5000, '-t', 8, '-c', conf.c];
|
||||||
|
|
||||||
bench.ab(path, args, function() {
|
bench.http(path, args, function() {
|
||||||
w1.destroy();
|
w1.destroy();
|
||||||
w2.destroy();
|
w2.destroy();
|
||||||
});
|
});
|
||||||
}, 2000);
|
}, 100);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ var bench = common.createBenchmark(main, {
|
|||||||
// unicode confuses ab on os x.
|
// unicode confuses ab on os x.
|
||||||
type: ['bytes', 'buffer'],
|
type: ['bytes', 'buffer'],
|
||||||
length: [4, 1024, 102400],
|
length: [4, 1024, 102400],
|
||||||
c: [50, 150]
|
c: [50, 500]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
@ -15,14 +15,9 @@ function main(conf) {
|
|||||||
var server = spawn(process.execPath, [simple]);
|
var server = spawn(process.execPath, [simple]);
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var path = '/' + conf.type + '/' + conf.length; //+ '/' + conf.chunks;
|
var path = '/' + conf.type + '/' + conf.length; //+ '/' + conf.chunks;
|
||||||
var args = ['-r', '-t', 5];
|
var args = ['-r', 5000, '-t', 8, '-c', conf.c];
|
||||||
|
|
||||||
if (+conf.c !== 1)
|
bench.http(path, args, function() {
|
||||||
args.push('-c', conf.c);
|
|
||||||
|
|
||||||
args.push('-k');
|
|
||||||
|
|
||||||
bench.ab(path, args, function() {
|
|
||||||
server.kill();
|
server.kill();
|
||||||
});
|
});
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user