forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcluster.js
More file actions
40 lines (35 loc) · 805 Bytes
/
cluster.js
File metadata and controls
40 lines (35 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'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;
bench.http({
path: path,
connections: conf.c
}, function() {
w1.destroy();
w2.destroy();
});
}, 100);
});
}