mirror of
https://github.com/nodejs/node.git
synced 2024-11-29 23:16:30 +01:00
22aa3d4899
PR-URL: https://github.com/nodejs/node/pull/12455 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
42 lines
872 B
JavaScript
42 lines
872 B
JavaScript
'use strict';
|
|
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'],
|
|
len: [4, 1024, 102400],
|
|
c: [50, 500]
|
|
});
|
|
} else {
|
|
var port = parseInt(process.env.PORT || PORT);
|
|
require('../fixtures/simple-http-server.js').listen(port);
|
|
}
|
|
|
|
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.len}`;
|
|
|
|
bench.http({
|
|
path: path,
|
|
connections: conf.c
|
|
}, function() {
|
|
w1.destroy();
|
|
w2.destroy();
|
|
});
|
|
}, 100);
|
|
});
|
|
}
|