diff options
author | isaacs <i@izs.me> | 2013-02-14 00:20:36 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-02-20 05:16:29 +0400 |
commit | ef08f0fbb19ba1e45721b759f37efd6574c400a3 (patch) | |
tree | 944b39d03c89fcb2539f6c939c7ac9c8aa66d8a7 /benchmark | |
parent | e850cbab1c83c9457f653c6241da5c74d2d0ab0e (diff) |
bench: Use wrk for http benchmarking
Remove ab, since it's no longer used.
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/common.js | 27 | ||||
-rw-r--r-- | benchmark/http/cluster.js | 7 | ||||
-rw-r--r-- | benchmark/http/http_simple.js | 11 |
3 files changed, 21 insertions, 24 deletions
diff --git a/benchmark/common.js b/benchmark/common.js index 289f17d1280..3c478bd0199 100644 --- a/benchmark/common.js +++ b/benchmark/common.js @@ -11,7 +11,6 @@ if (module === require.main) { process.exit(1); } - var path = require('path'); var fs = require('fs'); var dir = path.join(__dirname, type); var tests = fs.readdirSync(dir); @@ -59,16 +58,18 @@ function Benchmark(fn, options) { }); } -// run ab against a server. -Benchmark.prototype.ab = function(path, args, cb) { - var url = 'http://127.0.0.1:' + exports.PORT + path; - args.push(url); - +// benchmark an http server. +Benchmark.prototype.http = function(p, args, cb) { 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; - // console.error('ab %s', args.join(' ')); - var child = spawn('ab', args); + var url = 'http://127.0.0.1:' + exports.PORT + p; + + args = args.concat(url); + + var out = ''; + var child = spawn(wrk, args); child.stdout.setEncoding('utf8'); @@ -81,14 +82,14 @@ Benchmark.prototype.ab = function(path, args, cb) { cb(code); if (code) { - console.error('ab failed with ' + code); + console.error('wrk failed with ' + code); process.exit(code) } - var m = out.match(/Requests per second: +([0-9\.]+)/); + var m = out.match(regexp); var qps = m && +m[1]; if (!qps) { - process.stderr.write(out + '\n'); - console.error('ab produced strange output'); + console.error('%j', out); + console.error('wrk produced strange output'); process.exit(1); } self.report(+qps); diff --git a/benchmark/http/cluster.js b/benchmark/http/cluster.js index a8c7abe6896..12bb8d59467 100644 --- a/benchmark/http/cluster.js +++ b/benchmark/http/cluster.js @@ -7,7 +7,7 @@ if (cluster.isMaster) { // unicode confuses ab on os x. type: ['bytes', 'buffer'], length: [4, 1024, 102400], - c: [50, 150] + c: [50, 500] }); } else { require('../http_simple.js'); @@ -27,11 +27,12 @@ function main(conf) { setTimeout(function() { var path = '/' + conf.type + '/' + conf.length; 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(); w2.destroy(); }); - }, 2000); + }, 100); }); } diff --git a/benchmark/http/http_simple.js b/benchmark/http/http_simple.js index 2cef41f46f9..04a2a2911f2 100644 --- a/benchmark/http/http_simple.js +++ b/benchmark/http/http_simple.js @@ -5,7 +5,7 @@ var bench = common.createBenchmark(main, { // unicode confuses ab on os x. type: ['bytes', 'buffer'], length: [4, 1024, 102400], - c: [50, 150] + c: [50, 500] }); function main(conf) { @@ -15,14 +15,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 = ['-r', 5000, '-t', 8, '-c', conf.c]; - if (+conf.c !== 1) - args.push('-c', conf.c); - - args.push('-k'); - - bench.ab(path, args, function() { + bench.http(path, args, function() { server.kill(); }); }, 2000); |