From 1a18006bf0e65087a70391d0c65ef4e4e1870021 Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Mon, 10 Jul 2023 17:37:58 +0200 Subject: [PATCH] Fix results handling --- bin/plugin/commands/performance.js | 6 ++++-- test/performance/utils.js | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bin/plugin/commands/performance.js b/bin/plugin/commands/performance.js index 032c4d28141ab..0e8e755ba729c 100644 --- a/bin/plugin/commands/performance.js +++ b/bin/plugin/commands/performance.js @@ -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, } ); } @@ -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>>} */ const results = {}; + // Calculate medians from all rounds. for ( const testSuite of testSuites ) { results[ testSuite ] = {}; @@ -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 ) diff --git a/test/performance/utils.js b/test/performance/utils.js index 1110d1fcae143..e4f7b2281a6d5 100644 --- a/test/performance/utils.js +++ b/test/performance/utils.js @@ -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 ) ); }