You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
Reporting on the fly
This commit is contained in:
20
bench.js
20
bench.js
@@ -25,7 +25,8 @@ function next(){
|
||||
if (fn.length) {
|
||||
var pending = buffers.length;
|
||||
buffers.forEach(function(buf){
|
||||
fn(buf, function(){
|
||||
fn(buf, function(label){
|
||||
report(label);
|
||||
--pending || next();
|
||||
});
|
||||
});
|
||||
@@ -50,7 +51,7 @@ var queue = [
|
||||
while (n--) client.lpush('list', 'foo');
|
||||
client.lpush("list", buf, function(err, res) {
|
||||
curr['lpush ' + buf.length] = new Date - start;
|
||||
next();
|
||||
next('lpush ' + buf.length);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -62,11 +63,15 @@ var queue = [
|
||||
while (n--) client.lrange("mylist", 0, 99);
|
||||
client.lrange("mylist", 0, 99, function (err, res) {
|
||||
curr['lrange ' + buf.length] = new Date - start;
|
||||
next();
|
||||
next('lrange ' + buf.length);
|
||||
});
|
||||
},
|
||||
|
||||
report
|
||||
function(){
|
||||
fs.writeFileSync(path, JSON.stringify(curr), 'ascii');
|
||||
console.log();
|
||||
client.end();
|
||||
}
|
||||
];
|
||||
|
||||
client.on('connect', function(){
|
||||
@@ -79,8 +84,7 @@ client.on('connect', function(){
|
||||
next();
|
||||
});
|
||||
|
||||
function report() {
|
||||
for (var label in curr) {
|
||||
function report(label) {
|
||||
var p = prev[label] || 0
|
||||
, c = curr[label]
|
||||
, col = c > p
|
||||
@@ -95,7 +99,3 @@ function report() {
|
||||
console.log(' previously was \x1b[33m%d\x1b[0m ms faster', c - p);
|
||||
}
|
||||
}
|
||||
fs.writeFileSync(path, JSON.stringify(curr), 'ascii');
|
||||
console.log();
|
||||
client.end();
|
||||
}
|
Reference in New Issue
Block a user