Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a88918c
Run with Playwright in CI
WunderBart Jun 28, 2023
4ce6571
Print stdout on error
WunderBart Jun 28, 2023
f6d9851
Run build:packages to use e2e utils
WunderBart Jun 28, 2023
6fde09d
Extend timeout for the canvas spinner
WunderBart Jun 28, 2023
6f28c60
Add missing front end perf report
WunderBart Jun 28, 2023
b9b0440
Remove obsolete step
WunderBart Jun 29, 2023
ea6891f
Make the typing testing consistent
WunderBart Jun 29, 2023
aeae2ec
Improve post editor perf testing consistency
WunderBart Jul 4, 2023
309b9a2
Do not report slow tests
WunderBart Jul 5, 2023
b47d2b7
Use the same methodology for measuring post and site editors metrics
WunderBart Jul 5, 2023
0427a37
Make the results table transformer more readable
WunderBart Jul 5, 2023
542456e
Streamline the results processing p.1
WunderBart Jul 5, 2023
c06ab19
Improve visual step separation a tad :)
WunderBart Jul 5, 2023
df1216e
First step to separate metrics from the runner
WunderBart Jul 6, 2023
2e13186
Define the results file suffix
WunderBart Jul 6, 2023
ed1e0cc
Merge remote-tracking branch 'origin' into refactor/playwright-perfor…
WunderBart Jul 6, 2023
fecc1a0
cosmetic
WunderBart Jul 6, 2023
4a394d8
Fix matching pattern typo
WunderBart Jul 6, 2023
647ea57
Make performance.js comparison runner results-agnostic
WunderBart Jul 10, 2023
1a18006
Fix results handling
WunderBart Jul 10, 2023
f03e671
Use Playwright's attachments API to handle results
WunderBart Jul 10, 2023
5db75c3
Upload raw results as well
WunderBart Jul 10, 2023
da43808
Be consistent with calc utils
WunderBart Jul 11, 2023
00f641d
Streamline results handling
WunderBart Jul 11, 2023
2b9a5ac
Use the same sampling convention for front-end metrics
WunderBart Jul 11, 2023
1f8ecd1
Fix the metrics output in perf runner
WunderBart Jul 11, 2023
d649aac
tmp: compare performance with base branch
WunderBart Jul 12, 2023
ae40542
tmp: compare performance with base branch (run 2)
WunderBart Jul 12, 2023
18fe132
tmp: compare performance with base branch (run 3)
WunderBart Jul 12, 2023
8f15066
Revert "tmp: compare performance with base branch"
WunderBart Jul 12, 2023
b1d7f83
Remove unused code and do the switch
WunderBart Jul 12, 2023
e37cbc2
Merge remote-tracking branch 'origin' into refactor/playwright-perfor…
WunderBart Jul 12, 2023
2c305da
Fix site editor typing spec
WunderBart Jul 26, 2023
c9c625e
Merge remote-tracking branch 'origin' into refactor/playwright-perfor…
WunderBart Jul 26, 2023
bbae249
Add inline comment
WunderBart Jul 27, 2023
894896b
Expain why we need larger timeout for site editor visit util
WunderBart Jul 27, 2023
7ac254e
Use dirent for getting files from dir
WunderBart Jul 27, 2023
84bb262
Do not use the browser.newPage shortcut
WunderBart Jul 27, 2023
182fbc1
Merge remote-tracking branch 'origin' into refactor/playwright-perfor…
WunderBart Jul 27, 2023
1cf298a
Use trace buffer instead of tmp file
WunderBart Jul 27, 2023
f787f1e
Merge remote-tracking branch 'origin' into refactor/playwright-perfor…
WunderBart Aug 14, 2023
5a68bbc
Fix 'unterminated string' error
WunderBart Aug 14, 2023
d0d81fb
Fix 'unterminated string' error p.2
WunderBart Aug 14, 2023
37ef946
Make sure sanitized branch name is used for reading results json
WunderBart Aug 16, 2023
127b21e
Merge remote-tracking branch 'origin' into refactor/playwright-perfor…
WunderBart Aug 16, 2023
568d9d7
Prevent logging in via test.use() instead of creating new context
WunderBart Aug 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Be consistent with calc utils
  • Loading branch information
WunderBart committed Jul 11, 2023
commit da43808b8ad5f45862a72513a331dd95d8782c0f
30 changes: 19 additions & 11 deletions bin/plugin/commands/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,18 @@ function sanitizeBranchName( branch ) {
*
* @param {number[]} array
*
* @return {number} Median.
* @return {number|undefined} Median value or undefined if array empty.
*/
function median( array ) {
const mid = Math.floor( array.length / 2 ),
numbers = [ ...array ].sort( ( a, b ) => a - b );
return array.length % 2 !== 0
? numbers[ mid ]
: ( numbers[ mid - 1 ] + numbers[ mid ] ) / 2;
export function median( array ) {
if ( array.length === 0 ) return undefined;

const numbers = [ ...array ].sort( ( a, b ) => a - b );
const middleIndex = Math.floor( numbers.length / 2 );

if ( numbers.length % 2 === 0 ) {
return ( numbers[ middleIndex - 1 ] + numbers[ middleIndex ] ) / 2;
}
return numbers[ middleIndex ];
}

/**
Expand Down Expand Up @@ -355,10 +359,14 @@ async function runPerformanceTests( branches, options ) {
results[ testSuite ][ branch ] = {};

for ( const metric of metrics ) {
// @ts-ignore
const values = resultsRounds.map( ( item ) => item[ metric ] );
// @ts-ignore
results[ testSuite ][ branch ][ metric ] = median( values );
const values = resultsRounds
.map( ( round ) => round[ metric ] )
.filter( ( value ) => typeof value === 'number' );

const medianValue = median( values );
if ( medianValue !== undefined ) {
results[ testSuite ][ branch ][ metric ] = medianValue;
}
}
}

Expand Down
34 changes: 17 additions & 17 deletions test/performance/config/performance-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
/**
* Internal dependencies
*/
import { average, median, formatTime } from '../utils';
import { average, median, minimum, maximum, round } from '../utils';

export interface WPRawPerformanceResults {
timeToFirstByte: number[];
Expand Down Expand Up @@ -96,32 +96,32 @@ export function curateResults(
firstContentfulPaint: average( results.firstContentfulPaint ),
firstBlock: average( results.firstBlock ),
type: average( results.type ),
minType: Math.min( ...results.type ),
maxType: Math.max( ...results.type ),
minType: minimum( results.type ),
maxType: maximum( results.type ),
typeContainer: average( results.typeContainer ),
minTypeContainer: Math.min( ...results.typeContainer ),
maxTypeContainer: Math.max( ...results.typeContainer ),
minTypeContainer: minimum( results.typeContainer ),
maxTypeContainer: maximum( results.typeContainer ),
focus: average( results.focus ),
minFocus: Math.min( ...results.focus ),
maxFocus: Math.max( ...results.focus ),
minFocus: minimum( results.focus ),
maxFocus: maximum( results.focus ),
inserterOpen: average( results.inserterOpen ),
minInserterOpen: Math.min( ...results.inserterOpen ),
maxInserterOpen: Math.max( ...results.inserterOpen ),
minInserterOpen: minimum( results.inserterOpen ),
maxInserterOpen: maximum( results.inserterOpen ),
inserterSearch: average( results.inserterSearch ),
minInserterSearch: Math.min( ...results.inserterSearch ),
maxInserterSearch: Math.max( ...results.inserterSearch ),
minInserterSearch: minimum( results.inserterSearch ),
maxInserterSearch: maximum( results.inserterSearch ),
inserterHover: average( results.inserterHover ),
minInserterHover: Math.min( ...results.inserterHover ),
maxInserterHover: Math.max( ...results.inserterHover ),
minInserterHover: minimum( results.inserterHover ),
maxInserterHover: maximum( results.inserterHover ),
listViewOpen: average( results.listViewOpen ),
minListViewOpen: Math.min( ...results.listViewOpen ),
maxListViewOpen: Math.max( ...results.listViewOpen ),
minListViewOpen: minimum( results.listViewOpen ),
maxListViewOpen: maximum( results.listViewOpen ),
};
}

return Object.fromEntries(
Object.entries( output ).map( ( [ key, value ] ) => {
return [ key, formatTime( value ) ];
return [ key, round( value ) ];
} )
);
}
Expand Down Expand Up @@ -188,7 +188,7 @@ class PerformanceReporter implements Reporter {
const printableResults: Record< string, { value: string } > = {};

for ( const [ key, value ] of Object.entries( results ) ) {
if ( isFinite( value ) ) {
if ( typeof value === 'number' ) {
printableResults[ key ] = { value: `${ value } ms` };
}
}
Expand Down
75 changes: 42 additions & 33 deletions test/performance/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,48 @@
import path from 'path';
import { existsSync, readFileSync, unlinkSync } from 'fs';

export function sum( array ) {
if ( array.length === 0 ) return undefined;

return array.reduce( ( a, b ) => a + b, 0 );
}

export function average( array ) {
if ( array.length === 0 ) return undefined;

return sum( array ) / array.length;
}

export function median( array ) {
if ( array.length === 0 ) return undefined;

const numbers = [ ...array ].sort( ( a, b ) => a - b );
const middleIndex = Math.floor( numbers.length / 2 );

if ( numbers.length % 2 === 0 ) {
return ( numbers[ middleIndex - 1 ] + numbers[ middleIndex ] ) / 2;
}
return numbers[ middleIndex ];
}

export function minimum( array ) {
if ( array.length === 0 ) return undefined;

return Math.min( ...array );
}

export function maximum( array ) {
if ( array.length === 0 ) return undefined;

return Math.max( ...array );
}

export function round( number, decimalPlaces = 2 ) {
const factor = Math.pow( 10, decimalPlaces );

return Math.round( number * factor ) / factor;
}

export function readFile( filePath ) {
if ( ! existsSync( filePath ) ) {
throw new Error( `File does not exist: ${ filePath }` );
Expand Down Expand Up @@ -128,39 +170,6 @@ export async function getLoadingDurations( page ) {
} );
}

export function sum( arr ) {
return arr.reduce( ( a, b ) => a + b, 0 );
}

export function average( array ) {
return array.reduce( ( a, b ) => a + b, 0 ) / array.length;
}

export function median( array ) {
const mid = Math.floor( array.length / 2 ),
numbers = [ ...array ].sort( ( a, b ) => a - b );
return array.length % 2 !== 0
? numbers[ mid ]
: ( numbers[ mid - 1 ] + numbers[ mid ] ) / 2;
}

export function round( number, decimalPlaces = 2 ) {
const factor = Math.pow( 10, decimalPlaces );
return Math.round( number * factor ) / factor;
}

/**
* Rounds and format a time passed in milliseconds.
*
* @param {number} number
*
* @return {number} Formatted time.
*/
export function formatTime( number ) {
const factor = Math.pow( 10, 2 );
return Math.round( number * factor ) / factor;
}

export async function loadBlocksFromHtml( page, filepath ) {
if ( ! existsSync( filepath ) ) {
throw new Error( `File not found (${ filepath })` );
Expand Down