mirror of
https://github.com/liabru/matter-js.git
synced 2025-01-21 17:14:38 -05:00
improve performance measurement accuracy in tests
This commit is contained in:
parent
30b899c862
commit
cd289ec279
4 changed files with 9 additions and 7 deletions
|
@ -53,8 +53,8 @@
|
||||||
"test-all": "jest --no-cache",
|
"test-all": "jest --no-cache",
|
||||||
"test-save": "SAVE=true npm run test-node",
|
"test-save": "SAVE=true npm run test-node",
|
||||||
"test-watch": "npm run test-node -- --watch",
|
"test-watch": "npm run test-node -- --watch",
|
||||||
"test-node": "jest --no-cache ./test/Examples.spec.js",
|
"test-node": "node --expose-gc node_modules/.bin/jest --no-cache --runInBand ./test/Examples.spec.js",
|
||||||
"test-browser": "jest --no-cache ./test/Browser.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",
|
"changelog": "conventional-changelog -i CHANGELOG.md -s -r",
|
||||||
"release": "npm version --no-git-tag-version",
|
"release": "npm version --no-git-tag-version",
|
||||||
"preversion": "git checkout master && npm run lint && SAVE=true npm run test-all",
|
"preversion": "git checkout master && npm run lint && SAVE=true npm run test-all",
|
||||||
|
|
|
@ -30,6 +30,8 @@ const runExample = options => {
|
||||||
const consoleOriginal = global.console;
|
const consoleOriginal = global.console;
|
||||||
const logs = [];
|
const logs = [];
|
||||||
|
|
||||||
|
global.gc();
|
||||||
|
|
||||||
mock('matter-js', Matter);
|
mock('matter-js', Matter);
|
||||||
global.Matter = Matter;
|
global.Matter = Matter;
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,8 @@ const examples = Object.keys(Example).filter(key => {
|
||||||
|
|
||||||
const runExamples = async useDev => {
|
const runExamples = async useDev => {
|
||||||
const worker = new Worker(require.resolve('./ExampleWorker'), {
|
const worker = new Worker(require.resolve('./ExampleWorker'), {
|
||||||
enableWorkerThreads: true
|
enableWorkerThreads: true,
|
||||||
|
numWorkers: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await Promise.all(examples.map(name => worker.runExample({
|
const result = await Promise.all(examples.map(name => worker.runExample({
|
||||||
|
|
|
@ -256,9 +256,8 @@ const comparisonReport = (capturesDev, capturesBuild, buildVersion, save) => {
|
||||||
|
|
||||||
let perfChange = 1 - (totalTimeDev / totalTimeBuild);
|
let perfChange = 1 - (totalTimeDev / totalTimeBuild);
|
||||||
|
|
||||||
const perfChangeThreshold = 0.075;
|
const perfChangeThreshold = 0.01;
|
||||||
const perfChangeLarge = Math.abs(perfChange) > perfChangeThreshold;
|
perfChange = Math.abs(perfChange) > perfChangeThreshold ? perfChange : 0;
|
||||||
perfChange = perfChangeLarge ? perfChange : 0;
|
|
||||||
|
|
||||||
let similarityAvg = 0;
|
let similarityAvg = 0;
|
||||||
similarityEntries.forEach(([_, similarity]) => {
|
similarityEntries.forEach(([_, similarity]) => {
|
||||||
|
@ -288,7 +287,7 @@ const comparisonReport = (capturesDev, capturesBuild, buildVersion, save) => {
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}, '\n\n'),
|
}, '\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)}` : '',
|
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)}` : ''
|
intrinsicChangeCount > 0 ? `\n${format('▶', colors.White)} ${format((save ? diffCommand : diffSaveCommand), colors.BrightCyan)}` : ''
|
||||||
].join(' ');
|
].join(' ');
|
||||||
|
|
Loading…
Add table
Reference in a new issue