@@ -19,11 +19,12 @@ var TextAlign;
19
19
TextAlign["CENTER"] = "center";
20
20
})(TextAlign = exports.TextAlign || (exports.TextAlign = {}));
21
21
const center = (text, length) => text.padStart((text.length + length) / 2).padEnd(length);
22
- const formatShellCell = (cell) => {
22
+ const formatShellCell = (cell, length = 10 ) => {
23
23
const format = colors_1.default[cell.delta > 0 ? "red" : cell.delta < 0 ? "green" : "reset"];
24
24
return [
25
- format(cell.value.toLocaleString().padStart(10)),
26
- format((plusSign(cell.delta) + cell.delta.toLocaleString()).padStart(10)),
25
+ cell.value.toLocaleString().padStart(length) +
26
+ " " +
27
+ format(("(" + (plusSign(cell.delta) + cell.delta.toLocaleString()) + ")").padEnd(length)),
27
28
colors_1.default.bold(format((plusSign(cell.prcnt) + cell.prcnt.toFixed(2) + "%").padStart(8))),
28
29
];
29
30
};
@@ -34,11 +35,13 @@ const formatShellDiff = (diffs) => {
34
35
const COLS = [
35
36
{ txt: "", length: 0 },
36
37
{ txt: "Contract", length: maxContractLength },
38
+ { txt: "Deployment Cost (+/-)", length: 32 },
37
39
{ txt: "Method", length: maxMethodLength },
38
- { txt: "Min", length: 34 },
39
- { txt: "Avg", length: 34 },
40
- { txt: "Median", length: 34 },
41
- { txt: "Max", length: 34 },
40
+ { txt: "Min (+/-)", length: 32 },
41
+ { txt: "Avg (+/-)", length: 32 },
42
+ { txt: "Median (+/-)", length: 32 },
43
+ { txt: "Max (+/-)", length: 32 },
44
+ { txt: "# Calls (+/-)", length: 13 },
42
45
{ txt: "", length: 0 },
43
46
];
44
47
const header = COLS.map((entry) => colors_1.default.bold(center(entry.txt, entry.length || 0)))
@@ -54,11 +57,13 @@ const formatShellDiff = (diffs) => {
54
57
.map((method, methodIndex) => [
55
58
"",
56
59
colors_1.default.bold(colors_1.default.grey((methodIndex === 0 ? diff.name : "").padEnd(maxContractLength))),
60
+ ...(methodIndex === 0 ? (0, exports.formatShellCell)(diff.deploymentCost) : ["".padEnd(32)]),
57
61
colors_1.default.italic(method.name.padEnd(maxMethodLength)),
58
62
...(0, exports.formatShellCell)(method.min),
59
63
...(0, exports.formatShellCell)(method.avg),
60
64
...(0, exports.formatShellCell)(method.median),
61
65
...(0, exports.formatShellCell)(method.max),
66
+ (0, exports.formatShellCell)(method.calls, 6)[0],
62
67
"",
63
68
]
64
69
.join(" | ")
@@ -86,6 +91,7 @@ const formatMarkdownSummaryCell = (rows) => [
86
91
rows
87
92
.map((row) => plusSign(row.delta) +
88
93
row.delta.toLocaleString() +
94
+ " " +
89
95
(row.delta > 0 ? "β" : row.delta < 0 ? "β
" : "β"))
90
96
.join("<br />"),
91
97
rows.map((row) => "**" + plusSign(row.prcnt) + row.prcnt.toFixed(2) + "%**").join("<br />"),
@@ -96,7 +102,6 @@ const formatMarkdownFullCell = (rows) => [
96
102
" (" +
97
103
plusSign(row.delta) +
98
104
row.delta.toLocaleString() +
99
- (row.delta > 0 ? "β" : row.delta < 0 ? "β
" : "β") +
100
105
")")
101
106
.join("<br />"),
102
107
rows.map((row) => "**" + plusSign(row.prcnt) + row.prcnt.toFixed(2) + "%**").join("<br />"),
@@ -112,15 +117,17 @@ const MARKDOWN_SUMMARY_COLS = [
112
117
const MARKDOWN_DIFF_COLS = [
113
118
{ txt: "" },
114
119
{ txt: "Contract", align: TextAlign.LEFT },
120
+ { txt: "Deployment Cost (+/-)", align: TextAlign.RIGHT },
115
121
{ txt: "Method", align: TextAlign.LEFT },
116
- { txt: "Min", align: TextAlign.RIGHT },
122
+ { txt: "Min (+/-) ", align: TextAlign.RIGHT },
117
123
{ txt: "%", align: TextAlign.RIGHT },
118
- { txt: "Avg", align: TextAlign.RIGHT },
124
+ { txt: "Avg (+/-) ", align: TextAlign.RIGHT },
119
125
{ txt: "%", align: TextAlign.RIGHT },
120
- { txt: "Median", align: TextAlign.RIGHT },
126
+ { txt: "Median (+/-) ", align: TextAlign.RIGHT },
121
127
{ txt: "%", align: TextAlign.RIGHT },
122
- { txt: "Max", align: TextAlign.RIGHT },
128
+ { txt: "Max (+/-) ", align: TextAlign.RIGHT },
123
129
{ txt: "%", align: TextAlign.RIGHT },
130
+ { txt: "# Calls (+/-)", align: TextAlign.RIGHT },
124
131
{ txt: "" },
125
132
];
126
133
const formatMarkdownDiff = (title, diffs) => {
@@ -164,11 +171,13 @@ const formatMarkdownDiff = (title, diffs) => {
164
171
.flatMap((diff) => [
165
172
"",
166
173
`**${diff.name}**`,
174
+ formatMarkdownFullCell([diff.deploymentCost])[0],
167
175
diff.methods.map((method) => `_${method.name}_`).join("<br />"),
168
176
...formatMarkdownFullCell(diff.methods.map((method) => method.min)),
169
177
...formatMarkdownFullCell(diff.methods.map((method) => method.avg)),
170
178
...formatMarkdownFullCell(diff.methods.map((method) => method.median)),
171
179
...formatMarkdownFullCell(diff.methods.map((method) => method.max)),
180
+ formatMarkdownFullCell(diff.methods.map((method) => method.calls))[0],
172
181
"",
173
182
]
174
183
.join(" | ")
@@ -449,15 +458,18 @@ const computeDiffs = (sourceReports, compareReports) => {
449
458
const srcReport = sourceReports[reportName];
450
459
const cmpReport = compareReports[reportName];
451
460
return Object.assign(Object.assign({}, srcReport), { deploymentCost: (0, exports.variation)(cmpReport.deploymentCost, srcReport.deploymentCost), deploymentSize: (0, exports.variation)(cmpReport.deploymentSize, srcReport.deploymentSize), methods: Object.values(srcReport.methods)
452
- .map((methodReport) => (Object.assign(Object.assign({}, methodReport), { min: (0, exports.variation)(cmpReport.methods[methodReport.name].min, srcReport.methods[methodReport.name].min), avg: (0, exports.variation)(cmpReport.methods[methodReport.name].avg, srcReport.methods[methodReport.name].avg), median: (0, exports.variation)(cmpReport.methods[methodReport.name].median, srcReport.methods[methodReport.name].median), max: (0, exports.variation)(cmpReport.methods[methodReport.name].max, srcReport.methods[methodReport.name].max), calls: (0, exports.variation)(cmpReport.methods[methodReport.name].max , srcReport.methods[methodReport.name].max ) })))
461
+ .map((methodReport) => (Object.assign(Object.assign({}, methodReport), { min: (0, exports.variation)(cmpReport.methods[methodReport.name].min, srcReport.methods[methodReport.name].min), avg: (0, exports.variation)(cmpReport.methods[methodReport.name].avg, srcReport.methods[methodReport.name].avg), median: (0, exports.variation)(cmpReport.methods[methodReport.name].median, srcReport.methods[methodReport.name].median), max: (0, exports.variation)(cmpReport.methods[methodReport.name].max, srcReport.methods[methodReport.name].max), calls: (0, exports.variation)(cmpReport.methods[methodReport.name].calls , srcReport.methods[methodReport.name].calls ) })))
453
462
.filter((row) => row.min.delta !== 0 ||
454
463
row.avg.delta !== 0 ||
455
464
row.median.delta !== 0 ||
456
465
row.max.delta !== 0)
457
- .sort((method1, method2) => Math.max(Math.abs(method2.min.prcnt), Math.abs(method2.avg.prcnt), Math.abs(method2.median.prcnt), Math.abs(method2.max.prcnt)) -
458
- Math.max(Math.abs(method1.min.prcnt), Math.abs(method1.avg.prcnt), Math.abs(method1.median.prcnt), Math.abs(method1.max.prcnt))) });
466
+ .sort((method1, method2) => Math.abs(method2.avg.prcnt) - Math.abs(method1.avg.prcnt)) });
459
467
})
460
- .filter((diff) => diff.methods.length > 0);
468
+ .filter((diff) => diff.methods.length > 0 ||
469
+ diff.deploymentCost.delta !== 0 ||
470
+ diff.deploymentSize.delta !== 0)
471
+ .sort((diff1, diff2) => Math.max(...diff2.methods.map((method) => Math.abs(method.avg.prcnt))) -
472
+ Math.max(...diff1.methods.map((method) => Math.abs(method.avg.prcnt))));
461
473
};
462
474
exports.computeDiffs = computeDiffs;
463
475
0 commit comments