Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/http_bench.js')
-rw-r--r--benchmark/http_bench.js33
1 files changed, 23 insertions, 10 deletions
diff --git a/benchmark/http_bench.js b/benchmark/http_bench.js
index 0541667760a..a8f99e2f0e7 100644
--- a/benchmark/http_bench.js
+++ b/benchmark/http_bench.js
@@ -8,7 +8,8 @@ var options = {
port: 22344,
path: '/',
servers: 1,
- clients: 1
+ clients: 1,
+ clientConcurrentRequests: 2
};
for (var i = 2; i < process.argv.length; ++i) {
@@ -44,13 +45,25 @@ function patch(fun) {
function startMaster() {
if (!cluster.isMaster) return startServer();
- for (var i = ~~options.servers; i > 0; --i) cluster.fork();
+ var forkCount = 0;
+
+ cluster.on('online', function () {
+ forkCount = forkCount + 1;
+ if (forkCount === ~~options.servers) {
+ var args = [
+ __filename,
+ 'mode=client',
+ 'clientConcurrentRequests=' + options.clientConcurrentRequests
+ ];
+ for (var i = ~~options.clients; i > 0; --i) {
+ var cp = spawn(process.execPath, args);
+ cp.stdout.pipe(process.stdout);
+ cp.stderr.pipe(process.stderr);
+ }
+ }
+ });
- for (var i = ~~options.clients; i > 0; --i) {
- var cp = spawn(process.execPath, [__filename, 'mode=client']);
- cp.stdout.pipe(process.stdout);
- cp.stderr.pipe(process.stderr);
- }
+ for (var i = ~~options.servers; i > 0; --i) cluster.fork();
}
function startServer() {
@@ -73,9 +86,9 @@ function startServer() {
function startClient() {
// send off a bunch of concurrent requests
- // TODO make configurable
- sendRequest();
- sendRequest();
+ for (var i = ~~options.clientConcurrentRequests; i > 0; --i) {
+ sendRequest();
+ }
function sendRequest() {
var req = http.request(options, onConnection);