You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
chore - remove standard and use individual config
Standard is not as up to date and still uses a old eslint version. Instead, use the airbnb default with a couple of modifications. All required changes are included.
This commit is contained in:
@@ -2,32 +2,33 @@
|
||||
|
||||
// `node diffMultiBenchOutput.js beforeBench.txt afterBench.txt`
|
||||
|
||||
var fs = require('fs')
|
||||
var file1 = process.argv[2]
|
||||
var file2 = process.argv[3]
|
||||
const fs = require('fs')
|
||||
|
||||
const file1 = process.argv[2]
|
||||
const file2 = process.argv[3]
|
||||
|
||||
if (!file1 || !file2) {
|
||||
console.log('Please supply two file arguments:')
|
||||
var n = __filename
|
||||
let n = __filename
|
||||
n = n.substring(n.lastIndexOf('/', n.length))
|
||||
console.log(' node .' + n + ' benchBefore.txt benchAfter.txt\n')
|
||||
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')
|
||||
const beforeLines = fs.readFileSync(file1, 'utf8').split('\n')
|
||||
const afterLines = fs.readFileSync(file2, 'utf8').split('\n')
|
||||
|
||||
console.log('Comparing before,', file1, '(', beforeLines.length, 'lines)', 'to after,', file2, '(', afterLines.length, 'lines)')
|
||||
|
||||
function isWhitespace (s) {
|
||||
function isWhitespace(s) {
|
||||
return !!s.trim()
|
||||
}
|
||||
|
||||
function pad (input, len, chr, right) {
|
||||
var str = input.toString()
|
||||
function pad(input, len, chr, right) {
|
||||
let str = input.toString()
|
||||
chr = chr || ' '
|
||||
|
||||
if (right) {
|
||||
@@ -42,50 +43,44 @@ function pad (input, len, chr, right) {
|
||||
return str
|
||||
}
|
||||
|
||||
// green if greater than 0, red otherwise
|
||||
function humanizeDiff (num, unit, toFixed) {
|
||||
// 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(num.toFixed(toFixed || 0) + unit, 7)}`
|
||||
}
|
||||
return ' -' + pad(Math.abs(num).toFixed(toFixed || 0) + unit, 7)
|
||||
return ` -${pad(Math.abs(num).toFixed(toFixed || 0) + unit, 7)}`
|
||||
}
|
||||
|
||||
function commandName (words) {
|
||||
var line = words.join(' ')
|
||||
function commandName(words) {
|
||||
const line = words.join(' ')
|
||||
return line.substr(0, line.indexOf(','))
|
||||
}
|
||||
|
||||
beforeLines.forEach(function (b, i) {
|
||||
var a = afterLines[i]
|
||||
beforeLines.forEach((b, i) => {
|
||||
const 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)
|
||||
const bWords = b.split(' ').filter(isWhitespace)
|
||||
const 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
|
||||
})
|
||||
const ops = [bWords, aWords].map(words => +words.slice(-2, -1)).filter(Number.isNaN)
|
||||
if (ops.length !== 2) {
|
||||
return
|
||||
}
|
||||
var delta = ops[1] - ops[0]
|
||||
var pct = +((delta / ops[0]) * 100)
|
||||
let delta = ops[1] - ops[0]
|
||||
let 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
|
||||
const 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'
|
||||
const bigDelta = pct > 20 || pct < -20 ? ';1' : ''
|
||||
pct = `${humanizeDiff(pct, '', 2)}%`
|
||||
let 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)
|
||||
})
|
||||
|
@@ -1,16 +1,20 @@
|
||||
'use strict'
|
||||
|
||||
const Buffer = require('buffer').Buffer
|
||||
const { Buffer } = require('buffer')
|
||||
const path = require('path')
|
||||
const RedisProcess = require('../test/lib/redis-process')
|
||||
|
||||
let rp
|
||||
let clientNr = 0
|
||||
const redis = require('../index')
|
||||
|
||||
let totalTime = 0
|
||||
// eslint-disable-next-line
|
||||
const metrics = require('metrics')
|
||||
|
||||
const tests = []
|
||||
|
||||
function returnArg (name, def) {
|
||||
function returnArg(name, def) {
|
||||
const matches = process.argv.filter((entry) => {
|
||||
return entry.indexOf(`${name}=`) === 0
|
||||
})
|
||||
@@ -27,7 +31,7 @@ const clientOptions = {
|
||||
path: returnArg('socket') // '/tmp/redis.sock'
|
||||
}
|
||||
|
||||
function lpad (input, len, chr) {
|
||||
function lpad(input, len, chr) {
|
||||
let str = input.toString()
|
||||
chr = chr || ' '
|
||||
while (str.length < len) {
|
||||
@@ -41,7 +45,7 @@ metrics.Histogram.prototype.printLine = function () {
|
||||
return `${lpad((obj.mean / 1e6).toFixed(2), 6)}/${lpad((obj.max / 1e6).toFixed(2), 6)}`
|
||||
}
|
||||
|
||||
function Test (args) {
|
||||
function Test(args) {
|
||||
this.args = args
|
||||
this.args.pipeline = +pipeline
|
||||
this.callback = null
|
||||
@@ -116,7 +120,7 @@ Test.prototype.newClient = function (id) {
|
||||
}
|
||||
|
||||
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} `)
|
||||
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()
|
||||
return this.fillPipeline()
|
||||
}
|
||||
@@ -203,64 +207,110 @@ const veryLargeStr = (new Array((4 * 1024 * 1024) + 1).join('-'))
|
||||
const veryLargeBuf = Buffer.from(veryLargeStr)
|
||||
const 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: '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 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: '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 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: '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 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: '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 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: '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: '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: '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 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: '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 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: '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 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: '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 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}}))
|
||||
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 () {
|
||||
function next() {
|
||||
const test = tests.shift()
|
||||
if (test) {
|
||||
test.run(() => {
|
||||
|
Reference in New Issue
Block a user