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

chore: use standard

This commit is contained in:
Ruben Bridgewater
2017-05-06 07:06:52 +02:00
parent 5d29f541e9
commit f1a7bcd735
106 changed files with 10706 additions and 10978 deletions

View File

@@ -1,95 +1,91 @@
'use strict';
'use strict'
var fs = require('fs');
var metrics = require('metrics');
// `node diffMultiBenchOutput.js beforeBench.txt afterBench.txt`
var file1 = process.argv[2];
var file2 = process.argv[3];
// `node diffMultiBenchOutput.js beforeBench.txt afterBench.txt`
var fs = require('fs')
var file1 = process.argv[2]
var file2 = process.argv[3]
if (!file1 || !file2) {
console.log('Please supply two file arguments:');
var n = __filename;
n = n.substring(n.lastIndexOf('/', n.length));
console.log(' node .' + n + ' benchBefore.txt benchAfter.txt\n');
console.log('To generate the benchmark files, run');
console.log(' npm run benchmark > benchBefore.txt\n');
console.log('Thank you for benchmarking responsibly.');
return;
console.log('Please supply two file arguments:')
var n = __filename
n = n.substring(n.lastIndexOf('/', n.length))
console.log(' node .' + n + ' benchBefore.txt benchAfter.txt\n')
console.log('To generate the benchmark files, run')
console.log(' npm run benchmark > benchBefore.txt\n')
console.log('Thank you for benchmarking responsibly.')
process.exit(1)
}
var beforeLines = fs.readFileSync(file1, 'utf8').split('\n');
var afterLines = fs.readFileSync(file2, 'utf8').split('\n');
var totalOps = new metrics.Histogram.createUniformHistogram();
var beforeLines = fs.readFileSync(file1, 'utf8').split('\n')
var afterLines = fs.readFileSync(file2, 'utf8').split('\n')
console.log('Comparing before,', file1, '(', beforeLines.length, 'lines)', 'to after,', file2, '(', afterLines.length, 'lines)');
console.log('Comparing before,', file1, '(', beforeLines.length, 'lines)', 'to after,', file2, '(', afterLines.length, 'lines)')
function isWhitespace (s) {
return !!s.trim();
return !!s.trim()
}
function pad (input, len, chr, right) {
var str = input.toString();
chr = chr || ' ';
var str = input.toString()
chr = chr || ' '
if (right) {
while (str.length < len) {
str += chr;
}
} else {
while (str.length < len) {
str = chr + str;
}
if (right) {
while (str.length < len) {
str += chr
}
return str;
} else {
while (str.length < len) {
str = chr + str
}
}
return str
}
// green if greater than 0, red otherwise
function humanizeDiff (num, unit, toFixed) {
unit = unit || '';
if (num > 0) {
return ' +' + pad(num.toFixed(toFixed || 0) + unit, 7);
}
return ' -' + pad(Math.abs(num).toFixed(toFixed || 0) + unit, 7);
unit = unit || ''
if (num > 0) {
return ' +' + pad(num.toFixed(toFixed || 0) + unit, 7)
}
return ' -' + pad(Math.abs(num).toFixed(toFixed || 0) + unit, 7)
}
function commandName (words) {
var line = words.join(' ');
return line.substr(0, line.indexOf(','));
var line = words.join(' ')
return line.substr(0, line.indexOf(','))
}
beforeLines.forEach(function (b, i) {
var a = afterLines[i];
if (!a || !b || !b.trim() || !a.trim()) {
// console.log('#ignored#', '>'+a+'<', '>'+b+'<');
return;
}
var bWords = b.split(' ').filter(isWhitespace);
var aWords = a.split(' ').filter(isWhitespace);
var a = afterLines[i]
if (!a || !b || !b.trim() || !a.trim()) {
// console.log('#ignored#', '>'+a+'<', '>'+b+'<');
return
}
var bWords = b.split(' ').filter(isWhitespace)
var aWords = a.split(' ').filter(isWhitespace)
var ops = [bWords, aWords].map(function (words) {
// console.log(words);
return words.slice(-2, -1) | 0;
}).filter(function (num) {
var isNaN = !num && num !== 0;
return !isNaN;
});
if (ops.length !== 2) {
return;
}
var delta = ops[1] - ops[0];
var pct = +((delta / ops[0]) * 100);
ops[0] = pad(ops[0], 6);
ops[1] = pad(ops[1], 6);
totalOps.update(delta);
delta = humanizeDiff(delta);
var smallDelta = pct < 3 && pct > -3;
// Let's mark differences above 20% bold
var bigDelta = pct > 20 || pct < -20 ? ';1' : '';
pct = humanizeDiff(pct, '', 2) + '%';
var str = pad((commandName(aWords) === commandName(bWords) ? commandName(aWords) + ':' : '404:'), 14, false, true) +
(pad(ops.join(' -> '), 15) + ' ops/sec (∆' + delta + pct + ')');
str = (smallDelta ? '' : (/-[^>]/.test(str) ? '\x1b[31' : '\x1b[32') + bigDelta + 'm') + str + '\x1b[0m';
console.log(str);
});
console.log('Mean difference in ops/sec:', humanizeDiff(totalOps.mean(), '', 1));
var ops = [bWords, aWords].map(function (words) {
// console.log(words);
return words.slice(-2, -1) | 0
}).filter(function (num) {
var isNaN = !num && num !== 0
return !isNaN
})
if (ops.length !== 2) {
return
}
var delta = ops[1] - ops[0]
var pct = +((delta / ops[0]) * 100)
ops[0] = pad(ops[0], 6)
ops[1] = pad(ops[1], 6)
delta = humanizeDiff(delta)
var smallDelta = pct < 3 && pct > -3
// Let's mark differences above 20% bold
var bigDelta = pct > 20 || pct < -20 ? ';1' : ''
pct = humanizeDiff(pct, '', 2) + '%'
var str = pad((commandName(aWords) === commandName(bWords) ? commandName(aWords) + ':' : '404:'), 14, false, true) +
(pad(ops.join(' -> '), 15) + ' ops/sec (∆' + delta + pct + ')')
str = (smallDelta ? '' : (/-[^>]/.test(str) ? '\x1b[31' : '\x1b[32') + bigDelta + 'm') + str + '\x1b[0m'
console.log(str)
})

View File

@@ -1,295 +1,298 @@
'use strict';
'use strict'
var path = require('path');
var RedisProcess = require('../test/lib/redis-process');
var rp;
var clientNr = 0;
var redis = require('../index');
var totalTime = 0;
var metrics = require('metrics');
var tests = [];
var Buffer = require('safe-buffer').Buffer
var path = require('path')
var RedisProcess = require('../test/lib/redis-process')
var rp
var clientNr = 0
var redis = require('../index')
var totalTime = 0
var metrics = require('metrics')
var tests = []
// var bluebird = require('bluebird');
// bluebird.promisifyAll(redis.RedisClient.prototype);
// bluebird.promisifyAll(redis.Multi.prototype);
function returnArg (name, def) {
var matches = process.argv.filter(function (entry) {
return entry.indexOf(name + '=') === 0;
});
if (matches.length) {
return matches[0].substr(name.length + 1);
}
return def;
var matches = process.argv.filter(function (entry) {
return entry.indexOf(name + '=') === 0
})
if (matches.length) {
return matches[0].substr(name.length + 1)
}
return def
}
var numClients = returnArg('clients', 1);
var runTime = returnArg('time', 2500); // ms
var pipeline = returnArg('pipeline', 1); // number of concurrent commands
var versionsLogged = false;
var numClients = returnArg('clients', 1)
var runTime = returnArg('time', 2500) // ms
var pipeline = returnArg('pipeline', 1) // number of concurrent commands
var versionsLogged = false
var clientOptions = {
path: returnArg('socket') // '/tmp/redis.sock'
};
var smallStr, largeStr, smallBuf, largeBuf, veryLargeStr, veryLargeBuf, mgetArray;
path: returnArg('socket') // '/tmp/redis.sock'
}
var smallStr, largeStr, smallBuf, largeBuf, veryLargeStr, veryLargeBuf, mgetArray
function lpad (input, len, chr) {
var str = input.toString();
chr = chr || ' ';
while (str.length < len) {
str = chr + str;
}
return str;
var str = input.toString()
chr = chr || ' '
while (str.length < len) {
str = chr + str
}
return str
}
metrics.Histogram.prototype.printLine = function () {
var obj = this.printObj();
return lpad((obj.mean / 1e6).toFixed(2), 6) + '/' + lpad((obj.max / 1e6).toFixed(2), 6);
};
var obj = this.printObj()
return lpad((obj.mean / 1e6).toFixed(2), 6) + '/' + lpad((obj.max / 1e6).toFixed(2), 6)
}
function Test (args) {
this.args = args;
this.args.pipeline = +pipeline;
this.callback = null;
this.clients = [];
this.clientsReady = 0;
this.commandsSent = 0;
this.commandsCompleted = 0;
this.maxPipeline = +pipeline;
this.batchPipeline = this.args.batch || 0;
this.clientOptions = args.clientOptions || {};
this.clientOptions.connectTimeout = 1000;
if (clientOptions.path) {
this.clientOptions.path = clientOptions.path;
}
this.connectLatency = new metrics.Histogram();
this.readyLatency = new metrics.Histogram();
this.commandLatency = new metrics.Histogram();
this.args = args
this.args.pipeline = +pipeline
this.callback = null
this.clients = []
this.clientsReady = 0
this.commandsSent = 0
this.commandsCompleted = 0
this.maxPipeline = +pipeline
this.batchPipeline = this.args.batch || 0
this.clientOptions = args.clientOptions || {}
this.clientOptions.connectTimeout = 1000
if (clientOptions.path) {
this.clientOptions.path = clientOptions.path
}
this.connectLatency = new metrics.Histogram()
this.readyLatency = new metrics.Histogram()
this.commandLatency = new metrics.Histogram()
}
Test.prototype.run = function (callback) {
var i;
this.callback = callback;
for (i = 0; i < numClients ; i++) {
this.newClient(i);
}
};
Test.prototype.newClient = function (id) {
var self = this, newClient;
newClient = redis.createClient(this.clientOptions);
newClient.createTime = Date.now();
newClient.on('connect', function () {
self.connectLatency.update(Date.now() - newClient.createTime);
});
newClient.on('ready', function () {
if (!versionsLogged) {
console.log(
'clients: ' + numClients +
', NodeJS: ' + process.versions.node +
', Redis: ' + newClient.serverInfo.redis_version +
', connected by: ' + (clientOptions.path ? 'socket' : 'tcp')
);
versionsLogged = true;
}
self.readyLatency.update(Date.now() - newClient.createTime);
self.clientsReady++;
if (self.clientsReady === self.clients.length) {
self.onClientsReady();
}
});
// If no redis server is running, start one
newClient.on('error', function (err) {
if (err.code === 'CONNECTION_BROKEN') {
throw err;
}
if (rp) {
return;
}
rp = true;
var conf = '../test/conf/redis.conf';
RedisProcess.start(function (err, Rp) {
if (err) {
throw err;
}
rp = Rp;
}, path.resolve(__dirname, conf));
});
self.clients[id] = newClient;
};
Test.prototype.onClientsReady = function () {
process.stdout.write(lpad(this.args.descr, 13) + ', ' + (this.args.batch ? lpad('batch ' + this.args.batch, 9) : lpad(this.args.pipeline, 9)) + '/' + this.clientsReady + ' ');
this.testStart = Date.now();
this.fillPipeline();
};
Test.prototype.fillPipeline = function () {
var pipeline = this.commandsSent - this.commandsCompleted;
if (this.testStart < Date.now() - runTime) {
if (this.ended) {
return;
}
this.ended = true;
this.printStats();
this.stopClients();
return;
}
if (this.batchPipeline) {
this.batch();
} else {
while (pipeline < this.maxPipeline) {
this.commandsSent++;
pipeline++;
this.sendNext();
}
}
};
Test.prototype.batch = function () {
var self = this,
curClient = clientNr++ % this.clients.length,
start = process.hrtime(),
i = 0,
batch = this.clients[curClient].batch();
while (i++ < this.batchPipeline) {
this.commandsSent++;
batch[this.args.command](this.args.args);
}
batch.exec(function (err, res) {
if (err) {
throw err;
}
self.commandsCompleted += res.length;
self.commandLatency.update(process.hrtime(start)[1]);
self.fillPipeline();
});
};
Test.prototype.stopClients = function () {
var self = this;
this.clients.forEach(function (client, pos) {
if (pos === self.clients.length - 1) {
client.quit(function (err, res) {
self.callback();
});
} else {
client.quit();
}
});
};
Test.prototype.sendNext = function () {
var self = this,
curClient = this.commandsSent % this.clients.length,
start = process.hrtime();
this.clients[curClient][this.args.command](this.args.args, function (err, res) {
if (err) {
throw err;
}
self.commandsCompleted++;
self.commandLatency.update(process.hrtime(start)[1]);
self.fillPipeline();
});
};
Test.prototype.printStats = function () {
var duration = Date.now() - this.testStart;
totalTime += duration;
console.log('avg/max: ' + this.commandLatency.printLine() + lpad(duration, 5) + 'ms total, ' +
lpad(Math.round(this.commandsCompleted / (duration / 1000)), 7) + ' ops/sec');
};
smallStr = '1234';
smallBuf = new Buffer(smallStr);
largeStr = (new Array(4096 + 1).join('-'));
largeBuf = new Buffer(largeStr);
veryLargeStr = (new Array((4 * 1024 * 1024) + 1).join('-'));
veryLargeBuf = new Buffer(veryLargeStr);
mgetArray = (new Array(1025)).join('fooRand000000000001;').split(';');
tests.push(new Test({descr: 'PING', command: 'ping', args: []}));
tests.push(new Test({descr: 'PING', command: 'ping', args: [], batch: 50}));
tests.push(new Test({descr: 'SET 4B str', command: 'set', args: ['fooRand000000000000', smallStr]}));
tests.push(new Test({descr: 'SET 4B str', command: 'set', args: ['fooRand000000000000', smallStr], batch: 50}));
tests.push(new Test({descr: 'SET 4B buf', command: 'set', args: ['fooRand000000000000', smallBuf]}));
tests.push(new Test({descr: 'SET 4B buf', command: 'set', args: ['fooRand000000000000', smallBuf], batch: 50}));
tests.push(new Test({descr: 'GET 4B str', command: 'get', args: ['fooRand000000000000']}));
tests.push(new Test({descr: 'GET 4B str', command: 'get', args: ['fooRand000000000000'], batch: 50}));
tests.push(new Test({descr: 'GET 4B buf', command: 'get', args: ['fooRand000000000000'], clientOptions: { returnBuffers: true} }));
tests.push(new Test({descr: 'GET 4B buf', command: 'get', args: ['fooRand000000000000'], batch: 50, clientOptions: { returnBuffers: true} }));
tests.push(new Test({descr: 'SET 4KiB str', command: 'set', args: ['fooRand000000000001', largeStr]}));
tests.push(new Test({descr: 'SET 4KiB str', command: 'set', args: ['fooRand000000000001', largeStr], batch: 50}));
tests.push(new Test({descr: 'SET 4KiB buf', command: 'set', args: ['fooRand000000000001', largeBuf]}));
tests.push(new Test({descr: 'SET 4KiB buf', command: 'set', args: ['fooRand000000000001', largeBuf], batch: 50}));
tests.push(new Test({descr: 'GET 4KiB str', command: 'get', args: ['fooRand000000000001']}));
tests.push(new Test({descr: 'GET 4KiB str', command: 'get', args: ['fooRand000000000001'], batch: 50}));
tests.push(new Test({descr: 'GET 4KiB buf', command: 'get', args: ['fooRand000000000001'], clientOptions: { returnBuffers: true} }));
tests.push(new Test({descr: 'GET 4KiB buf', command: 'get', args: ['fooRand000000000001'], batch: 50, clientOptions: { returnBuffers: true} }));
tests.push(new Test({descr: 'INCR', command: 'incr', args: ['counterRand000000000000']}));
tests.push(new Test({descr: 'INCR', command: 'incr', args: ['counterRand000000000000'], batch: 50}));
tests.push(new Test({descr: 'LPUSH', command: 'lpush', args: ['mylist', smallStr]}));
tests.push(new Test({descr: 'LPUSH', command: 'lpush', args: ['mylist', smallStr], batch: 50}));
tests.push(new Test({descr: 'LRANGE 10', command: 'lrange', args: ['mylist', '0', '9']}));
tests.push(new Test({descr: 'LRANGE 10', command: 'lrange', args: ['mylist', '0', '9'], batch: 50}));
tests.push(new Test({descr: 'LRANGE 100', command: 'lrange', args: ['mylist', '0', '99']}));
tests.push(new Test({descr: 'LRANGE 100', command: 'lrange', args: ['mylist', '0', '99'], batch: 50}));
tests.push(new Test({descr: 'SET 4MiB str', command: 'set', args: ['fooRand000000000002', veryLargeStr]}));
tests.push(new Test({descr: 'SET 4MiB str', command: 'set', args: ['fooRand000000000002', veryLargeStr], batch: 20}));
tests.push(new Test({descr: 'SET 4MiB buf', command: 'set', args: ['fooRand000000000002', veryLargeBuf]}));
tests.push(new Test({descr: 'SET 4MiB buf', command: 'set', args: ['fooRand000000000002', veryLargeBuf], batch: 20}));
tests.push(new Test({descr: 'GET 4MiB str', command: 'get', args: ['fooRand000000000002']}));
tests.push(new Test({descr: 'GET 4MiB str', command: 'get', args: ['fooRand000000000002'], batch: 20}));
tests.push(new Test({descr: 'GET 4MiB buf', command: 'get', args: ['fooRand000000000002'], clientOptions: { returnBuffers: true} }));
tests.push(new Test({descr: 'GET 4MiB buf', command: 'get', args: ['fooRand000000000002'], batch: 20, clientOptions: { returnBuffers: true} }));
tests.push(new Test({descr: 'MGET 4MiB str', command: 'mget', args: mgetArray}));
tests.push(new Test({descr: 'MGET 4MiB str', command: 'mget', args: mgetArray, batch: 20}));
tests.push(new Test({descr: 'MGET 4MiB buf', command: 'mget', args: mgetArray, clientOptions: { returnBuffers: true} }));
tests.push(new Test({descr: 'MGET 4MiB buf', command: 'mget', args: mgetArray, batch: 20, clientOptions: { returnBuffers: true} }));
function next () {
var test = tests.shift();
if (test) {
test.run(function () {
next();
});
} else if (rp) {
// Stop the redis process if started by the benchmark
rp.stop(function () {
rp = undefined;
next();
});
} else {
console.log('End of tests. Total time elapsed:', totalTime, 'ms');
process.exit(0);
}
var i
this.callback = callback
for (i = 0; i < numClients; i++) {
this.newClient(i)
}
}
next();
Test.prototype.newClient = function (id) {
var self = this
var newClient
newClient = redis.createClient(this.clientOptions)
newClient.createTime = Date.now()
newClient.on('connect', function () {
self.connectLatency.update(Date.now() - newClient.createTime)
})
newClient.on('ready', function () {
if (!versionsLogged) {
console.log(
'clients: ' + numClients +
', NodeJS: ' + process.versions.node +
', Redis: ' + newClient.serverInfo.redis_version +
', connected by: ' + (clientOptions.path ? 'socket' : 'tcp')
)
versionsLogged = true
}
self.readyLatency.update(Date.now() - newClient.createTime)
self.clientsReady++
if (self.clientsReady === self.clients.length) {
self.onClientsReady()
}
})
// If no redis server is running, start one
newClient.on('error', function (err) {
if (err.code === 'CONNECTION_BROKEN') {
throw err
}
if (rp) {
return
}
rp = true
var conf = '../test/conf/redis.conf'
RedisProcess.start(function (err, Rp) {
if (err) {
throw err
}
rp = Rp
}, path.resolve(__dirname, conf))
})
self.clients[id] = newClient
}
Test.prototype.onClientsReady = function () {
process.stdout.write(lpad(this.args.descr, 13) + ', ' + (this.args.batch ? lpad('batch ' + this.args.batch, 9) : lpad(this.args.pipeline, 9)) + '/' + this.clientsReady + ' ')
this.testStart = Date.now()
this.fillPipeline()
}
Test.prototype.fillPipeline = function () {
var pipeline = this.commandsSent - this.commandsCompleted
if (this.testStart < Date.now() - runTime) {
if (this.ended) {
return
}
this.ended = true
this.printStats()
this.stopClients()
return
}
if (this.batchPipeline) {
this.batch()
} else {
while (pipeline < this.maxPipeline) {
this.commandsSent++
pipeline++
this.sendNext()
}
}
}
Test.prototype.batch = function () {
var self = this
var curClient = clientNr++ % this.clients.length
var start = process.hrtime()
var i = 0
var batch = this.clients[curClient].batch()
while (i++ < this.batchPipeline) {
this.commandsSent++
batch[this.args.command](this.args.args)
}
batch.exec(function (err, res) {
if (err) {
throw err
}
self.commandsCompleted += res.length
self.commandLatency.update(process.hrtime(start)[1])
self.fillPipeline()
})
}
Test.prototype.stopClients = function () {
var self = this
this.clients.forEach(function (client, pos) {
if (pos === self.clients.length - 1) {
client.quit(function (err, res) {
if (err) throw err
self.callback()
})
} else {
client.quit()
}
})
}
Test.prototype.sendNext = function () {
var self = this
var curClient = this.commandsSent % this.clients.length
var start = process.hrtime()
this.clients[curClient][this.args.command](this.args.args, function (err, res) {
if (err) {
throw err
}
self.commandsCompleted++
self.commandLatency.update(process.hrtime(start)[1])
self.fillPipeline()
})
}
Test.prototype.printStats = function () {
var duration = Date.now() - this.testStart
totalTime += duration
console.log('avg/max: ' + this.commandLatency.printLine() + lpad(duration, 5) + 'ms total, ' +
lpad(Math.round(this.commandsCompleted / (duration / 1000)), 7) + ' ops/sec')
}
smallStr = '1234'
smallBuf = Buffer.from(smallStr)
largeStr = (new Array(4096 + 1).join('-'))
largeBuf = Buffer.from(largeStr)
veryLargeStr = (new Array((4 * 1024 * 1024) + 1).join('-'))
veryLargeBuf = Buffer.from(veryLargeStr)
mgetArray = (new Array(1025)).join('fooRand000000000001;').split(';')
tests.push(new Test({descr: 'PING', command: 'ping', args: []}))
tests.push(new Test({descr: 'PING', command: 'ping', args: [], batch: 50}))
tests.push(new Test({descr: 'SET 4B str', command: 'set', args: ['fooRand000000000000', smallStr]}))
tests.push(new Test({descr: 'SET 4B str', command: 'set', args: ['fooRand000000000000', smallStr], batch: 50}))
tests.push(new Test({descr: 'SET 4B buf', command: 'set', args: ['fooRand000000000000', smallBuf]}))
tests.push(new Test({descr: 'SET 4B buf', command: 'set', args: ['fooRand000000000000', smallBuf], batch: 50}))
tests.push(new Test({descr: 'GET 4B str', command: 'get', args: ['fooRand000000000000']}))
tests.push(new Test({descr: 'GET 4B str', command: 'get', args: ['fooRand000000000000'], batch: 50}))
tests.push(new Test({descr: 'GET 4B buf', command: 'get', args: ['fooRand000000000000'], clientOptions: {returnBuffers: true}}))
tests.push(new Test({descr: 'GET 4B buf', command: 'get', args: ['fooRand000000000000'], batch: 50, clientOptions: {returnBuffers: true}}))
tests.push(new Test({descr: 'SET 4KiB str', command: 'set', args: ['fooRand000000000001', largeStr]}))
tests.push(new Test({descr: 'SET 4KiB str', command: 'set', args: ['fooRand000000000001', largeStr], batch: 50}))
tests.push(new Test({descr: 'SET 4KiB buf', command: 'set', args: ['fooRand000000000001', largeBuf]}))
tests.push(new Test({descr: 'SET 4KiB buf', command: 'set', args: ['fooRand000000000001', largeBuf], batch: 50}))
tests.push(new Test({descr: 'GET 4KiB str', command: 'get', args: ['fooRand000000000001']}))
tests.push(new Test({descr: 'GET 4KiB str', command: 'get', args: ['fooRand000000000001'], batch: 50}))
tests.push(new Test({descr: 'GET 4KiB buf', command: 'get', args: ['fooRand000000000001'], clientOptions: {returnBuffers: true}}))
tests.push(new Test({descr: 'GET 4KiB buf', command: 'get', args: ['fooRand000000000001'], batch: 50, clientOptions: {returnBuffers: true}}))
tests.push(new Test({descr: 'INCR', command: 'incr', args: ['counterRand000000000000']}))
tests.push(new Test({descr: 'INCR', command: 'incr', args: ['counterRand000000000000'], batch: 50}))
tests.push(new Test({descr: 'LPUSH', command: 'lpush', args: ['mylist', smallStr]}))
tests.push(new Test({descr: 'LPUSH', command: 'lpush', args: ['mylist', smallStr], batch: 50}))
tests.push(new Test({descr: 'LRANGE 10', command: 'lrange', args: ['mylist', '0', '9']}))
tests.push(new Test({descr: 'LRANGE 10', command: 'lrange', args: ['mylist', '0', '9'], batch: 50}))
tests.push(new Test({descr: 'LRANGE 100', command: 'lrange', args: ['mylist', '0', '99']}))
tests.push(new Test({descr: 'LRANGE 100', command: 'lrange', args: ['mylist', '0', '99'], batch: 50}))
tests.push(new Test({descr: 'SET 4MiB str', command: 'set', args: ['fooRand000000000002', veryLargeStr]}))
tests.push(new Test({descr: 'SET 4MiB str', command: 'set', args: ['fooRand000000000002', veryLargeStr], batch: 20}))
tests.push(new Test({descr: 'SET 4MiB buf', command: 'set', args: ['fooRand000000000002', veryLargeBuf]}))
tests.push(new Test({descr: 'SET 4MiB buf', command: 'set', args: ['fooRand000000000002', veryLargeBuf], batch: 20}))
tests.push(new Test({descr: 'GET 4MiB str', command: 'get', args: ['fooRand000000000002']}))
tests.push(new Test({descr: 'GET 4MiB str', command: 'get', args: ['fooRand000000000002'], batch: 20}))
tests.push(new Test({descr: 'GET 4MiB buf', command: 'get', args: ['fooRand000000000002'], clientOptions: {returnBuffers: true}}))
tests.push(new Test({descr: 'GET 4MiB buf', command: 'get', args: ['fooRand000000000002'], batch: 20, clientOptions: {returnBuffers: true}}))
tests.push(new Test({descr: 'MGET 4MiB str', command: 'mget', args: mgetArray}))
tests.push(new Test({descr: 'MGET 4MiB str', command: 'mget', args: mgetArray, batch: 20}))
tests.push(new Test({descr: 'MGET 4MiB buf', command: 'mget', args: mgetArray, clientOptions: {returnBuffers: true}}))
tests.push(new Test({descr: 'MGET 4MiB buf', command: 'mget', args: mgetArray, batch: 20, clientOptions: {returnBuffers: true}}))
function next () {
var test = tests.shift()
if (test) {
test.run(function () {
next()
})
} else if (rp) {
// Stop the redis process if started by the benchmark
rp.stop(function () {
rp = undefined
next()
})
} else {
console.log('End of tests. Total time elapsed:', totalTime, 'ms')
process.exit(0)
}
}
next()