Skip to content

Commit

Permalink
added filesize to test comparison report
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Nov 21, 2021
1 parent 55feb89 commit b3a8aa3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
7 changes: 5 additions & 2 deletions test/ExampleWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ const runExample = options => {
totalDuration += duration[0] * 1e9 + duration[1];
totalMemory += process.memoryUsage().heapUsed;

for (let p = 0; p < engine.pairs.list.length; p += 1) {
const pair = engine.pairs.list[p];
const pairsList = engine.pairs.list;
const pairsListLength = engine.pairs.list.length;

for (let p = 0; p < pairsListLength; p += 1) {
const pair = pairsList[p];
const separation = pair.separation - pair.slop;

if (pair.isActive && !pair.isSensor) {
Expand Down
9 changes: 7 additions & 2 deletions test/Examples.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

jest.setTimeout(30 * 1000);

const fs = require('fs');

const {
comparisonReport,
logReport,
Expand Down Expand Up @@ -54,11 +56,14 @@ afterAll(async () => {
const dev = await capturesDev;
const build = await capturesBuild;

const buildSize = fs.statSync('./build/matter.min.js').size;
const devSize = fs.statSync('./build/matter.dev.min.js').size;

console.log(
'Examples ran against previous release and current version\n\n'
'Examples ran against previous release and current build\n\n'
+ logReport(build, `release`) + '\n'
+ logReport(dev, `current`) + '\n'
+ comparisonReport(dev, build, MatterBuild.version, saveComparison)
+ comparisonReport(dev, build, devSize, buildSize, MatterBuild.version, saveComparison)
);
});

Expand Down
21 changes: 12 additions & 9 deletions test/TestTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ const logReport = (captures, version) => {
+ (report ? report : ' None\n');
};

const comparisonReport = (capturesDev, capturesBuild, buildVersion, save) => {
const comparisonReport = (capturesDev, capturesBuild, devSize, buildSize, buildVersion, save) => {
const similaritys = captureSimilarityExtrinsic(capturesDev, capturesBuild);
const similarityEntries = Object.entries(similaritys);
const devIntrinsicsChanged = {};
Expand Down Expand Up @@ -267,8 +267,10 @@ const comparisonReport = (capturesDev, capturesBuild, buildVersion, save) => {
capturePerformance.sort((a, b) => a.name.localeCompare(b.name));
similarityEntries.sort((a, b) => a[1] - b[1]);

let perfChange = noiseThreshold(1 - (totalTimeDev / totalTimeBuild), 0.01);
let memoryChange = noiseThreshold((totalMemoryDev / totalMemoryBuild) - 1, 0.01);
const perfChange = noiseThreshold(1 - (totalTimeDev / totalTimeBuild), 0.01);
const memoryChange = noiseThreshold((totalMemoryDev / totalMemoryBuild) - 1, 0.01);
const overlapChange = (totalOverlapDev / (totalOverlapBuild || 1)) - 1;
const filesizeChange = (devSize / buildSize) - 1;

let similarityAvg = 0;
similarityEntries.forEach(([_, similarity]) => {
Expand All @@ -277,20 +279,21 @@ const comparisonReport = (capturesDev, capturesBuild, buildVersion, save) => {

similarityAvg /= similarityEntries.length;

const overlapChange = (totalOverlapDev / (totalOverlapBuild || 1)) - 1;

const report = (breakEvery, format) => [
[`Output comparison of ${similarityEntries.length}`,
`examples against previous release ${format('matter-js@' + buildVersion, colors.Yellow)}`
].join(' '),
`\n\n${format('Similarity', colors.White)}`,
`${format(toPercent(similarityAvg), similarityAvg === 1 ? colors.Green : colors.Yellow)}%`,
`${format('Overlap', colors.White)}`,
`${format((overlapChange >= 0 ? '+' : '-') + toPercent(Math.abs(overlapChange)), overlapChange <= 0 ? colors.Green : colors.Yellow)}%`,
`${format('Performance', colors.White)}`,
`${format((perfChange >= 0 ? '+' : '-') + toPercentRound(Math.abs(perfChange)), perfChange >= 0 ? colors.Green : colors.Red)}%`,
`${format((perfChange >= 0 ? '+' : '-') + toPercentRound(Math.abs(perfChange)), perfChange >= 0 ? colors.Green : colors.Yellow)}%`,
`${format('Memory', colors.White)}`,
`${format((memoryChange >= 0 ? '+' : '-') + toPercentRound(Math.abs(memoryChange)), memoryChange <= 0 ? colors.Green : colors.Red)}%`,
`${format('Overlap', colors.White)}`,
`${format((overlapChange >= 0 ? '+' : '-') + toPercent(Math.abs(overlapChange)), overlapChange <= 0 ? colors.Green : colors.Red)}%`,
`${format((memoryChange >= 0 ? '+' : '-') + toPercentRound(Math.abs(memoryChange)), memoryChange <= 0 ? colors.Green : colors.Yellow)}%`,
`${format('Filesize', colors.White)}`,
`${format((filesizeChange >= 0 ? '+' : '-') + toPercent(Math.abs(filesizeChange)), filesizeChange <= 0 ? colors.Green : colors.Yellow)}%`,
`${format(`${(devSize / 1024).toPrecision(4)} KB`, colors.White)}`,
capturePerformance.reduce((output, p, i) => {
output += `${p.name} `;
output += `${similarityRatings(similaritys[p.name])} `;
Expand Down

0 comments on commit b3a8aa3

Please sign in to comment.