mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 23:43:09 +01:00
4bb529d972
Apply strict mode to benchmark code. PR-URL: https://github.com/nodejs/node/pull/5336 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
39 lines
813 B
JavaScript
39 lines
813 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'],
|
|
length: [4, 1024, 102400],
|
|
c: [50, 500]
|
|
});
|
|
} 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 = ['-d', '10s', '-t', 8, '-c', conf.c];
|
|
|
|
bench.http(path, args, function() {
|
|
w1.destroy();
|
|
w2.destroy();
|
|
});
|
|
}, 100);
|
|
});
|
|
}
|