You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
Take connection count from command line.
This commit is contained in:
@@ -3,8 +3,8 @@
|
|||||||
var redis = require("./index"),
|
var redis = require("./index"),
|
||||||
request = require("request"),
|
request = require("request"),
|
||||||
stats_url = "mjr.couchone.com/bench",
|
stats_url = "mjr.couchone.com/bench",
|
||||||
client_count = 50,
|
client_count = process.argv[2] || 50,
|
||||||
ops_count = 10000,
|
ops_count = 20000,
|
||||||
clients = new Array(client_count),
|
clients = new Array(client_count),
|
||||||
i, tests = {}, results = {}, test_list;
|
i, tests = {}, results = {}, test_list;
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ tests.connections = function () {
|
|||||||
function start_connection (num) {
|
function start_connection (num) {
|
||||||
results[name].starts[num] = new Date();
|
results[name].starts[num] = new Date();
|
||||||
clients[num] = redis.createClient();
|
clients[num] = redis.createClient();
|
||||||
if (num < client_count) {
|
if (num < (client_count - 1)) {
|
||||||
clients[num].on("connect", handle_connection(num));
|
clients[num].on("connect", handle_connection(num));
|
||||||
} else {
|
} else {
|
||||||
clients[num].on("connect", function () {
|
clients[num].on("connect", function () {
|
||||||
@@ -130,17 +130,19 @@ tests.connections = function () {
|
|||||||
test_complete(name);
|
test_complete(name);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
clients[num].on("error", function (msg) {
|
clients[num].on("error", function (msg) {
|
||||||
console.log("Connect problem:" + msg.stack);
|
console.log("Connect problem:" + msg.stack);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("Starting " + client_count + " connections.");
|
||||||
init_test(name);
|
init_test(name);
|
||||||
start_connection(0);
|
start_connection(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
tests.ping = function () {
|
tests.ping = function () {
|
||||||
var name = "PING (multi bulk)";
|
var name = "PING (mb)";
|
||||||
|
|
||||||
init_test(name);
|
init_test(name);
|
||||||
spread_command(name, "ping", []);
|
spread_command(name, "ping", []);
|
||||||
@@ -206,6 +208,9 @@ function run_next() {
|
|||||||
tests[cur_test]();
|
tests[cur_test]();
|
||||||
} else {
|
} else {
|
||||||
console.log("End of tests.");
|
console.log("End of tests.");
|
||||||
|
clients.forEach(function (client) {
|
||||||
|
client.quit();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user