mirror of https://github.com/lukechilds/node.git
isaacs
12 years ago
3 changed files with 69 additions and 11 deletions
@ -0,0 +1,37 @@ |
|||
var common = require('../common.js'); |
|||
var PORT = common.PORT; |
|||
|
|||
var cluster = require('cluster'); |
|||
if (cluster.isMaster) { |
|||
var bench = common.createBenchmark(main, { |
|||
// unicode confuses ab on os x.
|
|||
type: ['bytes', 'buffer'], |
|||
length: [4, 1024, 102400], |
|||
c: [50, 150] |
|||
}); |
|||
} else { |
|||
require('../http_simple.js'); |
|||
} |
|||
|
|||
function main(conf) { |
|||
process.env.PORT = PORT; |
|||
var workers = 0; |
|||
var w1 = cluster.fork(); |
|||
var w2 = cluster.fork(); |
|||
|
|||
cluster.on('listening', function() { |
|||
workers++; |
|||
if (workers < 2) |
|||
return; |
|||
|
|||
setTimeout(function() { |
|||
var path = '/' + conf.type + '/' + conf.length; |
|||
var args = ['-r', '-t', 5, '-c', conf.c, '-k']; |
|||
|
|||
bench.ab(path, args, function() { |
|||
w1.destroy(); |
|||
w2.destroy(); |
|||
}); |
|||
}, 2000); |
|||
}); |
|||
} |
@ -0,0 +1,29 @@ |
|||
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] |
|||
}); |
|||
|
|||
function main(conf) { |
|||
process.env.PORT = PORT; |
|||
var spawn = require('child_process').spawn; |
|||
var simple = require('path').resolve(__dirname, '../http_simple.js'); |
|||
var server = spawn(process.execPath, [simple]); |
|||
setTimeout(function() { |
|||
var path = '/' + conf.type + '/' + conf.length; //+ '/' + conf.chunks;
|
|||
var args = ['-r', '-t', 5]; |
|||
|
|||
if (+conf.c !== 1) |
|||
args.push('-c', conf.c); |
|||
|
|||
args.push('-k'); |
|||
|
|||
bench.ab(path, args, function() { |
|||
server.kill(); |
|||
}); |
|||
}, 2000); |
|||
} |
Loading…
Reference in new issue