Skip to content

Commit

Permalink
improve performance measurement accuracy in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Nov 19, 2021
1 parent 30b899c commit cd289ec
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"test-all": "jest --no-cache",
"test-save": "SAVE=true npm run test-node",
"test-watch": "npm run test-node -- --watch",
"test-node": "jest --no-cache ./test/Examples.spec.js",
"test-browser": "jest --no-cache ./test/Browser.spec.js",
"test-node": "node --expose-gc node_modules/.bin/jest --no-cache --runInBand ./test/Examples.spec.js",
"test-browser": "node --expose-gc node_modules/.bin/jest --no-cache --runInBand ./test/Browser.spec.js",
"changelog": "conventional-changelog -i CHANGELOG.md -s -r",
"release": "npm version --no-git-tag-version",
"preversion": "git checkout master && npm run lint && SAVE=true npm run test-all",
Expand Down
2 changes: 2 additions & 0 deletions test/ExampleWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const runExample = options => {
const consoleOriginal = global.console;
const logs = [];

global.gc();

mock('matter-js', Matter);
global.Matter = Matter;

Expand Down
3 changes: 2 additions & 1 deletion test/Examples.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const examples = Object.keys(Example).filter(key => {

const runExamples = async useDev => {
const worker = new Worker(require.resolve('./ExampleWorker'), {
enableWorkerThreads: true
enableWorkerThreads: true,
numWorkers: 1
});

const result = await Promise.all(examples.map(name => worker.runExample({
Expand Down
7 changes: 3 additions & 4 deletions test/TestTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,8 @@ const comparisonReport = (capturesDev, capturesBuild, buildVersion, save) => {

let perfChange = 1 - (totalTimeDev / totalTimeBuild);

const perfChangeThreshold = 0.075;
const perfChangeLarge = Math.abs(perfChange) > perfChangeThreshold;
perfChange = perfChangeLarge ? perfChange : 0;
const perfChangeThreshold = 0.01;
perfChange = Math.abs(perfChange) > perfChangeThreshold ? perfChange : 0;

let similarityAvg = 0;
similarityEntries.forEach(([_, similarity]) => {
Expand Down Expand Up @@ -288,7 +287,7 @@ const comparisonReport = (capturesDev, capturesBuild, buildVersion, save) => {
}
return output;
}, '\n\n'),
`\nwhere · no change ● extrinsics changed ◆ intrinsics changed\n`,
`\n\nwhere · no change ● extrinsics changed ◆ intrinsics changed\n`,
similarityAvg < 1 ? `\n${format('▶', colors.White)} ${format(compareCommand + '=' + 120 + '#' + similarityEntries[0][0], colors.BrightCyan)}` : '',
intrinsicChangeCount > 0 ? `\n${format('▶', colors.White)} ${format((save ? diffCommand : diffSaveCommand), colors.BrightCyan)}` : ''
].join(' ');
Expand Down

0 comments on commit cd289ec

Please sign in to comment.