Skip to content

Commit

Permalink
Throw away 1st measurement to avoid caching quirks
Browse files Browse the repository at this point in the history
  • Loading branch information
sgomes committed Feb 9, 2023
1 parent 23acde2 commit 0ef78ce
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
23 changes: 16 additions & 7 deletions packages/e2e-tests/specs/performance/post-editor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,14 @@ describe( 'Post Editor Performance', () => {
await saveDraft();
const draftURL = await page.url();

let i = 5;
// Number of sample measurements to take.
const samples = 5;
// Number of throwaway measurements to perform before recording samples.
// Having at least one helps ensure that caching quirks don't manifest in
// the results.
const throwaway = 1;

let i = throwaway + samples;
while ( i-- ) {
await page.close();
page = await browser.newPage();
Expand All @@ -126,12 +133,14 @@ describe( 'Post Editor Performance', () => {
firstBlock,
} = await getLoadingDurations();

results.serverResponse.push( serverResponse );
results.firstPaint.push( firstPaint );
results.domContentLoaded.push( domContentLoaded );
results.loaded.push( loaded );
results.firstContentfulPaint.push( firstContentfulPaint );
results.firstBlock.push( firstBlock );
if ( i < samples ) {
results.serverResponse.push( serverResponse );
results.firstPaint.push( firstPaint );
results.domContentLoaded.push( domContentLoaded );
results.loaded.push( loaded );
results.firstContentfulPaint.push( firstContentfulPaint );
results.firstBlock.push( firstBlock );
}
}
} );

Expand Down
28 changes: 21 additions & 7 deletions packages/e2e-tests/specs/performance/site-editor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ describe( 'Site Editor Performance', () => {
it( 'Loading', async () => {
const editorURL = await page.url();

let i = 3;
// Number of sample measurements to take.
const samples = 3;
// Number of throwaway measurements to perform before recording samples.
// Having at least one helps ensure that caching quirks don't manifest in
// the results.
const throwaway = 1;

let i = throwaway + samples;

// Measuring loading time.
while ( i-- ) {
Expand All @@ -114,16 +121,23 @@ describe( 'Site Editor Performance', () => {
firstBlock,
} = await getLoadingDurations();

results.serverResponse.push( serverResponse );
results.firstPaint.push( firstPaint );
results.domContentLoaded.push( domContentLoaded );
results.loaded.push( loaded );
results.firstContentfulPaint.push( firstContentfulPaint );
results.firstBlock.push( firstBlock );
if ( i < samples ) {
results.serverResponse.push( serverResponse );
results.firstPaint.push( firstPaint );
results.domContentLoaded.push( domContentLoaded );
results.loaded.push( loaded );
results.firstContentfulPaint.push( firstContentfulPaint );
results.firstBlock.push( firstBlock );
}
}
} );

it( 'Typing', async () => {
await page.waitForSelector( '.edit-site-visual-editor', {
timeout: 120000,
} );
await canvas().waitForSelector( '.wp-block', { timeout: 120000 } );

// Measuring typing performance inside the post content.
await canvas().waitForSelector(
'[data-type="core/post-content"] [data-type="core/paragraph"]'
Expand Down

0 comments on commit 0ef78ce

Please sign in to comment.