You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
Remove snack_case and always use camelCase
This commit is contained in:
committed by
Ruben Bridgewater
parent
a86c998a64
commit
28afc33c9a
@@ -2,7 +2,7 @@
|
||||
|
||||
var fs = require('fs');
|
||||
var metrics = require('metrics');
|
||||
// `node diff_multi_bench_output.js beforeBench.txt afterBench.txt`
|
||||
// `node diffMultiBenchOutput.js beforeBench.txt afterBench.txt`
|
||||
var file1 = process.argv[2];
|
||||
var file2 = process.argv[3];
|
||||
|
||||
@@ -17,13 +17,13 @@ if (!file1 || !file2) {
|
||||
return;
|
||||
}
|
||||
|
||||
var before_lines = fs.readFileSync(file1, 'utf8').split('\n');
|
||||
var after_lines = fs.readFileSync(file2, 'utf8').split('\n');
|
||||
var total_ops = new metrics.Histogram.createUniformHistogram();
|
||||
var beforeLines = fs.readFileSync(file1, 'utf8').split('\n');
|
||||
var afterLines = fs.readFileSync(file2, 'utf8').split('\n');
|
||||
var totalOps = new metrics.Histogram.createUniformHistogram();
|
||||
|
||||
console.log('Comparing before,', file1, '(', before_lines.length, 'lines)', 'to after,', file2, '(', after_lines.length, 'lines)');
|
||||
console.log('Comparing before,', file1, '(', beforeLines.length, 'lines)', 'to after,', file2, '(', afterLines.length, 'lines)');
|
||||
|
||||
function is_whitespace (s) {
|
||||
function isWhitespace (s) {
|
||||
return !!s.trim();
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ function pad (input, len, chr, right) {
|
||||
}
|
||||
|
||||
// green if greater than 0, red otherwise
|
||||
function humanize_diff (num, unit, toFixed) {
|
||||
function humanizeDiff (num, unit, toFixed) {
|
||||
unit = unit || '';
|
||||
if (num > 0) {
|
||||
return ' +' + pad(num.toFixed(toFixed || 0) + unit, 7);
|
||||
@@ -52,21 +52,21 @@ function humanize_diff (num, unit, toFixed) {
|
||||
return ' -' + pad(Math.abs(num).toFixed(toFixed || 0) + unit, 7);
|
||||
}
|
||||
|
||||
function command_name (words) {
|
||||
function commandName (words) {
|
||||
var line = words.join(' ');
|
||||
return line.substr(0, line.indexOf(','));
|
||||
}
|
||||
|
||||
before_lines.forEach(function (b, i) {
|
||||
var a = after_lines[i];
|
||||
beforeLines.forEach(function (b, i) {
|
||||
var a = afterLines[i];
|
||||
if (!a || !b || !b.trim() || !a.trim()) {
|
||||
// console.log('#ignored#', '>'+a+'<', '>'+b+'<');
|
||||
return;
|
||||
}
|
||||
var b_words = b.split(' ').filter(is_whitespace);
|
||||
var a_words = a.split(' ').filter(is_whitespace);
|
||||
var bWords = b.split(' ').filter(isWhitespace);
|
||||
var aWords = a.split(' ').filter(isWhitespace);
|
||||
|
||||
var ops = [b_words, a_words].map(function (words) {
|
||||
var ops = [bWords, aWords].map(function (words) {
|
||||
// console.log(words);
|
||||
return words.slice(-2, -1) | 0;
|
||||
}).filter(function (num) {
|
||||
@@ -80,16 +80,16 @@ before_lines.forEach(function (b, i) {
|
||||
var pct = +((delta / ops[0]) * 100);
|
||||
ops[0] = pad(ops[0], 6);
|
||||
ops[1] = pad(ops[1], 6);
|
||||
total_ops.update(delta);
|
||||
delta = humanize_diff(delta);
|
||||
var small_delta = pct < 3 && pct > -3;
|
||||
totalOps.update(delta);
|
||||
delta = humanizeDiff(delta);
|
||||
var smallDelta = pct < 3 && pct > -3;
|
||||
// Let's mark differences above 20% bold
|
||||
var big_delta = pct > 20 || pct < -20 ? ';1' : '';
|
||||
pct = humanize_diff(pct, '', 2) + '%';
|
||||
var str = pad((command_name(a_words) === command_name(b_words) ? command_name(a_words) + ':' : '404:'), 14, false, true) +
|
||||
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 = (small_delta ? '' : (/-[^>]/.test(str) ? '\x1b[31' : '\x1b[32') + big_delta + 'm') + str + '\x1b[0m';
|
||||
str = (smallDelta ? '' : (/-[^>]/.test(str) ? '\x1b[31' : '\x1b[32') + bigDelta + 'm') + str + '\x1b[0m';
|
||||
console.log(str);
|
||||
});
|
||||
|
||||
console.log('Mean difference in ops/sec:', humanize_diff(total_ops.mean(), '', 1));
|
||||
console.log('Mean difference in ops/sec:', humanizeDiff(totalOps.mean(), '', 1));
|
||||
|
Reference in New Issue
Block a user