Skip to content

Commit

Permalink
Build/Test Tools: Fix performance tests logging script after [58076].
Browse files Browse the repository at this point in the history
Removes some unintended debug cruft, whoops!

See #59900.

git-svn-id: https://develop.svn.wordpress.org/trunk@58077 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
swissspidy committed May 2, 2024
1 parent 53b75a1 commit 73b7808
Showing 1 changed file with 13 additions and 26 deletions.
39 changes: 13 additions & 26 deletions tests/performance/log-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,26 @@ const testSuiteMap = {
*/
const afterStats = parseFile( 'performance-results.json' );

if ( ! afterStats.length ) {
console.error( 'No results file found' );
process.exit( 1 );
}

/**
* @type {Array<{file: string, title: string, results: Record<string,number[]>[]}>}
*/
const baseStats = parseFile( 'base-performance-results.json' );

if ( ! baseStats.length ) {
console.error( 'No base results file found' );
process.exit( 1 );
}

/**
* @type {Record<string, number>}
*/
const metrics = {};

/**
* @type {Record<string, number>}
*/
Expand All @@ -65,38 +76,14 @@ for ( const { title, results } of afterStats ) {
}
}

process.exit( 0 );

/**
* Gets the array of metrics from a list of results.
*
* @param {Object[]} results A list of results to format.
* @return {Object} Metrics.
*/
const formatResults = ( results ) => {
return results.reduce( ( result, { key, file } ) => {
return {
...result,
...Object.fromEntries(
Object.entries( parseFile( file ) ?? {} ).map(
( [ metric, value ] ) => [
key + '-' + metric,
median( value ),
]
)
),
};
}, {} );
};

const data = new TextEncoder().encode(
JSON.stringify( {
branch,
hash,
baseHash,
timestamp: parseInt( timestamp, 10 ),
metrics: formatResults( testResults ),
baseMetrics: formatResults( baseResults ),
metrics: metrics,
baseMetrics: baseMetrics,
} )
);

Expand Down

0 comments on commit 73b7808

Please sign in to comment.