1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-09 00:22:08 +03:00

Restructured bench.js

This commit is contained in:
Tj Holowaychuk
2010-09-17 18:05:31 -07:00
parent 729debf993
commit 6e2b52cd93

View File

@@ -12,25 +12,35 @@ var client = redis.createClient()
, curr = {} , curr = {}
, prev; , prev;
function next(){
queue.shift()();
}
var queue = [
function(){
client.flushall(next);
},
function(){
var n = times
, start = new Date;
while (n--) client.lpush('list', 'foo');
client.lpush("list", "bar", function(err, res) {
curr.lpush = new Date - start;
next();
});
},
report
];
client.on('connect', function(){ client.on('connect', function(){
try { try {
prev = JSON.parse(fs.readFileSync(path, 'ascii')); prev = JSON.parse(fs.readFileSync(path, 'ascii'));
} catch (err) { } catch (err) {
prev = {}; prev = {};
} }
benchmark();
});
function benchmark() {
var n = times
, start = new Date;
console.log('\n %d:', times); console.log('\n %d:', times);
while (n--) client.lpush('list', 'foo'); next();
client.lpush("list", "bar", function(err, res) {
curr.lpush = new Date - start;
report();
}); });
}
function report() { function report() {
for (var label in curr) { for (var label in curr) {