Created
September 28, 2010 05:04
-
-
Save JakSprats/600440 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Module dependencies. | |
*/ | |
var redis = require('./index'); | |
var client = redis.createClient(), | |
times = 800000, | |
curr = {}, | |
start; | |
function next(){ | |
var fn = queue.shift(); | |
if (fn.length) { | |
var pending = 1; | |
fn("key", function(label){ | |
var dur = new Date - start; | |
report(label, dur); | |
--pending || next(); | |
}); | |
} else { | |
fn(); | |
} | |
} | |
var queue = [ | |
// FLUSHALL | |
function(){ | |
client.flushall(next); | |
}, | |
function(buf, next){ | |
var n = times; | |
start = new Date; | |
while (n--) client.set('key_' + n, 'val_' + n); | |
client.set("key", buf, function(err, res) { | |
next('SET'); | |
}); | |
}, | |
function(buf, next){ | |
var n = times; | |
start = new Date; | |
while (n--) client.get("key_" + n); | |
client.get("key", function (err, res) { | |
next('GET'); | |
}); | |
}, | |
function(){ | |
client.end(); | |
} | |
]; | |
client.on('connect', function(){ | |
console.log('NUM: %d:', times); | |
next(); | |
}); | |
function report(label, c) { | |
console.log(' %s: ', label, (times/c)*1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment