You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
Benchmarking different buffer sizes
This commit is contained in:
32
bench.js
32
bench.js
@@ -8,12 +8,30 @@ var redis = require('./index')
|
||||
|
||||
var client = redis.createClient()
|
||||
, path = '/tmp/redis-bench'
|
||||
, times = 20000
|
||||
, times = 10000
|
||||
, curr = {}
|
||||
, prev;
|
||||
|
||||
var buffers = [
|
||||
new Buffer('hello')
|
||||
, new Buffer(Array(129).join('-'))
|
||||
, new Buffer(Array(257).join('-'))
|
||||
, new Buffer(Array(1025).join('-'))
|
||||
, new Buffer(Array(1025 * 4).join('-'))
|
||||
];
|
||||
|
||||
function next(){
|
||||
queue.shift()();
|
||||
var fn = queue.shift();
|
||||
if (fn.length) {
|
||||
var pending = buffers.length;
|
||||
buffers.forEach(function(buf){
|
||||
fn(buf, function(){
|
||||
--pending || next();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
fn();
|
||||
}
|
||||
}
|
||||
|
||||
var queue = [
|
||||
@@ -26,24 +44,24 @@ var queue = [
|
||||
|
||||
// LPUSH
|
||||
|
||||
function(){
|
||||
function(buf, next){
|
||||
var n = times
|
||||
, start = new Date;
|
||||
while (n--) client.lpush('list', 'foo');
|
||||
client.lpush("list", "bar", function(err, res) {
|
||||
curr.lpush = new Date - start;
|
||||
client.lpush("list", buf, function(err, res) {
|
||||
curr['lpush ' + buf.length] = new Date - start;
|
||||
next();
|
||||
});
|
||||
},
|
||||
|
||||
// LRANGE
|
||||
|
||||
function(){
|
||||
function(buf, next){
|
||||
var n = times
|
||||
, start = new Date;
|
||||
while (n--) client.lrange("mylist", 0, 99);
|
||||
client.lrange("mylist", 0, 99, function (err, res) {
|
||||
curr.lrange = new Date - start;
|
||||
curr['lrange ' + buf.length] = new Date - start;
|
||||
next();
|
||||
});
|
||||
},
|
||||
|
Reference in New Issue
Block a user