You've already forked node-redis
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:
32
bench.js
32
bench.js
@@ -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) {
|
||||||
|
Reference in New Issue
Block a user