Changeset 58077
- Timestamp:
- 05/02/2024 02:40:30 PM (13 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/performance/log-results.js
r58076 r58077 32 32 const afterStats = parseFile( 'performance-results.json' ); 33 33 34 if ( ! afterStats.length ) { 35 console.error( 'No results file found' ); 36 process.exit( 1 ); 37 } 38 34 39 /** 35 40 * @type {Array<{file: string, title: string, results: Record<string,number[]>[]}>} … … 37 42 const baseStats = parseFile( 'base-performance-results.json' ); 38 43 44 if ( ! baseStats.length ) { 45 console.error( 'No base results file found' ); 46 process.exit( 1 ); 47 } 48 39 49 /** 40 50 * @type {Record<string, number>} 41 51 */ 42 52 const metrics = {}; 53 43 54 /** 44 55 * @type {Record<string, number>} … … 66 77 } 67 78 68 process.exit( 0 );69 70 /**71 * Gets the array of metrics from a list of results.72 *73 * @param {Object[]} results A list of results to format.74 * @return {Object} Metrics.75 */76 const formatResults = ( results ) => {77 return results.reduce( ( result, { key, file } ) => {78 return {79 ...result,80 ...Object.fromEntries(81 Object.entries( parseFile( file ) ?? {} ).map(82 ( [ metric, value ] ) => [83 key + '-' + metric,84 median( value ),85 ]86 )87 ),88 };89 }, {} );90 };91 92 79 const data = new TextEncoder().encode( 93 80 JSON.stringify( { … … 96 83 baseHash, 97 84 timestamp: parseInt( timestamp, 10 ), 98 metrics: formatResults( testResults ),99 baseMetrics: formatResults( baseResults ),85 metrics: metrics, 86 baseMetrics: baseMetrics, 100 87 } ) 101 88 );
Note: See TracChangeset
for help on using the changeset viewer.