Skip to content

Commit

Permalink
Remove counts, unify formatting in reporter vs CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed May 15, 2024
1 parent cd450ae commit f1e32b6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bin/plugin/commands/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function formatValue( metric, value ) {
function printStats( m, s ) {
const pp = fixed( ( 100 * ( s.q75 - s.q50 ) ) / s.q50 );
const mp = fixed( ( 100 * ( s.q50 - s.q25 ) ) / s.q50 );
return `${ formatValue( m, s.q50 ) } +${ pp }% -${ mp }% (${ s.cnt })`;
return `${ formatValue( m, s.q50 ) } +${ pp }% -${ mp }%`;
}

/**
Expand Down
30 changes: 23 additions & 7 deletions test/performance/config/performance-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ export function curateResults(
.filter( ( [ _, value ] ) => value !== undefined )
);
}

function formatValue( metric: string, value: number ) {
if ( 'wpMemoryUsage' === metric ) {
return `${ ( value / Math.pow( 10, 6 ) ).toFixed( 2 ) } MB`;
}

if ( 'wpDbQueries' === metric ) {
return value.toString();
}

return `${ value } ms`;
}

class PerformanceReporter implements Reporter {
private results: Record< string, WPPerformanceResults >;

Expand Down Expand Up @@ -180,13 +193,16 @@ class PerformanceReporter implements Reporter {
for ( const [ testSuite, results ] of Object.entries( this.results ) ) {
const printableResults: Record< string, { value: string } > = {};

for ( const [ key, value ] of Object.entries( results ) ) {
const p = round( value.q75 - value.q50 );
const pp = round( 100 * ( p / value.q50 ) );
const m = round( value.q50 - value.q25 );
const mp = round( 100 * ( m / value.q50 ) );
printableResults[ key ] = {
value: `${ value.q50 } ±${ p }/${ m } ms (±${ pp }/${ mp }%) (${ value.cnt })`,
for ( const [ metric, value ] of Object.entries( results ) ) {
const valueStr = formatValue( metric, value.q50 );
const pp = round(
( 100 * ( value.q75 - value.q50 ) ) / value.q50
);
const mp = round(
( 100 * ( value.q50 - value.q25 ) ) / value.q50
);
printableResults[ metric ] = {
value: `${ valueStr } +${ pp }% -${ mp }%`,
};
}

Expand Down

0 comments on commit f1e32b6

Please sign in to comment.