Skip to content

Commit de04c00

Browse files
committed
improve test comparison report
1 parent ca2fe75 commit de04c00

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

test/TestTools.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const intrinsicProps = [
3131
const colors = { Red: 31, Green: 32, Yellow: 33, White: 37, BrightWhite: 90, BrightCyan: 36 };
3232
const color = (text, number) => number ? `\x1b[${number}m${text}\x1b[0m` : text;
3333
const limit = (val, precision=3) => parseFloat(val.toPrecision(precision));
34-
const toPercent = val => (100 * val).toPrecision(3);
34+
const toPercent = val => (100 * val).toFixed(3);
3535
const toPercentRound = val => Math.round(100 * val);
3636

3737
const requireUncached = path => {
@@ -294,13 +294,10 @@ const comparisonReport = (capturesDev, capturesBuild, devSize, buildSize, buildV
294294
`${format(toPercent(similarityAvg), similarityAvg === 1 ? colors.Green : colors.Yellow)}%`,
295295
`${format('Overlap', colors.White)}`,
296296
`${format((overlapChange >= 0 ? '+' : '-') + toPercent(Math.abs(overlapChange)), overlapChange <= 0 ? colors.Green : colors.Yellow)}%`,
297-
`${format('Performance', colors.White)}`,
297+
`${format('Performance ~', colors.White)}`,
298298
`${format((perfChange >= 0 ? '+' : '-') + toPercentRound(Math.abs(perfChange)), perfChange >= 0 ? colors.Green : colors.Yellow)}%`,
299-
`${format('Memory', colors.White)}`,
299+
`${format('Memory ~', colors.White)}`,
300300
`${format((memoryChange >= 0 ? '+' : '-') + toPercentRound(Math.abs(memoryChange)), memoryChange <= 0 ? colors.Green : colors.Yellow)}%`,
301-
`${format('Filesize', colors.White)}`,
302-
`${format((filesizeChange >= 0 ? '+' : '-') + toPercent(Math.abs(filesizeChange)), filesizeChange <= 0 ? colors.Green : colors.Yellow)}%`,
303-
`${format(`${(devSize / 1024).toPrecision(4)} KB`, colors.White)}`,
304301
capturePerformance.reduce((output, p, i) => {
305302
output += `${p.name} `;
306303
output += `${similarityRatings(similaritys[p.name])} `;
@@ -312,7 +309,10 @@ const comparisonReport = (capturesDev, capturesBuild, devSize, buildSize, buildV
312309
}, '\n\n'),
313310
`\n\nwhere · no change ● extrinsics changed ◆ intrinsics changed\n`,
314311
similarityAvg < 1 ? `\n${format('▶', colors.White)} ${format(compareCommand + '=' + 120 + '#' + similarityEntries[0][0], colors.BrightCyan)}` : '',
315-
intrinsicChangeCount > 0 ? `\n${format('▶', colors.White)} ${format((save ? diffCommand : diffSaveCommand), colors.BrightCyan)}` : ''
312+
intrinsicChangeCount > 0 ? `\n${format('▶', colors.White)} ${format((save ? diffCommand : diffSaveCommand), colors.BrightCyan)}` : '',
313+
`\n\n${format('Filesize', colors.White)}`,
314+
`${format((filesizeChange >= 0 ? '+' : '-') + toPercent(Math.abs(filesizeChange)), filesizeChange <= 0 ? colors.Green : colors.Yellow)}%`,
315+
`${format(`${(devSize / 1024).toPrecision(4)} KB`, colors.White)}`,
316316
].join(' ');
317317

318318
if (save) {

0 commit comments

Comments
 (0)