Skip to content

Commit

Permalink
Fix results handling
Browse files Browse the repository at this point in the history
  • Loading branch information
WunderBart committed Jul 10, 2023
1 parent 647ea57 commit 1a18006
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions bin/plugin/commands/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async function runTestSuite( testSuite, performanceTestDirectory, runKey ) {
{
...process.env,
WP_ARTIFACTS_PATH: ARTIFACTS_PATH,
RESULTS_FILENAME: runKey + RESULTS_FILE_SUFFIX,
RESULTS_ID: runKey,
}
);
}
Expand Down Expand Up @@ -333,12 +333,14 @@ async function runPerformanceTests( branches, options ) {
* 4- Formatting and saving the results.
*/

// Load curated results from each round.
const resultFiles = getFilesFromDir( ARTIFACTS_PATH ).filter( ( file ) =>
file.endsWith( RESULTS_FILE_SUFFIX )
);
/** @type {Record<string,Record<string, Record<string, number>>>} */
const results = {};

// Calculate medians from all rounds.
for ( const testSuite of testSuites ) {
results[ testSuite ] = {};

Expand All @@ -360,7 +362,7 @@ async function runPerformanceTests( branches, options ) {
}
}

// Save curated results to file.
// Save calculated results to file.
fs.writeFileSync(
path.join( ARTIFACTS_PATH, testSuite + RESULTS_FILE_SUFFIX ),
JSON.stringify( results[ testSuite ], null, 2 )
Expand Down
12 changes: 6 additions & 6 deletions test/performance/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ export function getTraceFilePath() {
}

export function saveResultsFile( testFilename, results, isRaw = false ) {
const resultsFilename =
process.env.RESULTS_FILENAME ||
`${ path.basename( testFilename, '.spec.js' ) }.performance-results${
isRaw ? '.raw' : ''
}.json`;
const basename =
process.env.RESULTS_ID || path.basename( testFilename, '.spec.js' );
const filename = `${ basename }.performance-results${
isRaw ? '.raw' : ''
}.json`;

return writeFileSync(
path.join( process.env.WP_ARTIFACTS_PATH, resultsFilename ),
path.join( process.env.WP_ARTIFACTS_PATH, filename ),
JSON.stringify( results, null, 2 )
);
}
Expand Down

0 comments on commit 1a18006

Please sign in to comment.