0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2025-01-20 17:10:11 -05:00

improve performance measurement accuracy in tests

This commit is contained in:
liabru 2021-11-19 20:30:12 +00:00
parent 30b899c862
commit cd289ec279
4 changed files with 9 additions and 7 deletions

View file

@ -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",

View file

@ -30,6 +30,8 @@ const runExample = options => {
const consoleOriginal = global.console;
const logs = [];
global.gc();
mock('matter-js', Matter);
global.Matter = Matter;

View file

@ -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({

View file

@ -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]) => {
@ -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(' ');