Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks to ad load time testing #1407

Merged
merged 6 commits into from
Jun 10, 2024
Merged
Changes from 1 commit
Commits
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
Next Next commit
Add more test articles and run through 3 times
emma-imber committed Jun 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit c8a6638d4ebdb46dae42e165ae064cf43a50ef5f
64 changes: 33 additions & 31 deletions playwright/benchmark/test-ad-load-time.spec.ts
Original file line number Diff line number Diff line change
@@ -41,47 +41,49 @@ const interceptCommercial = (page: Page) =>
test.describe.configure({ mode: 'parallel' });

test.describe('Test how long top-above-nav takes to load', () => {
for (const article of loadTimePages) {
test(`${article.path}`, async ({ page }, testInfo) => {
await interceptCommercial(page);
for (let i = 0; i < 3; i++) {
for (const article of loadTimePages) {
test(`${article.path}`, async ({ page }, testInfo) => {
await interceptCommercial(page);

const client = await page.context().newCDPSession(page);
const client = await page.context().newCDPSession(page);

await client.send(
'Network.emulateNetworkConditions',
networkConditions,
);

await page.setViewportSize(viewport);
await client.send(
'Network.emulateNetworkConditions',
networkConditions,
);

await loadPage(page, article.path);
await page.setViewportSize(viewport);

const startRenderingTime = Date.now();
await loadPage(page, article.path);

await waitForSlot(page, 'top-above-nav');
const startRenderingTime = Date.now();

const renderingTime = Date.now() - startRenderingTime;
await waitForSlot(page, 'top-above-nav');

console.log(`Ad rendered in ${renderingTime} ms`);
const renderingTime = Date.now() - startRenderingTime;

const file = resolve(
__dirname,
`../../benchmark-results/${testInfo.project.name}/ad-rendering-time-${testInfo.workerIndex}.txt`,
);
console.log(`Ad rendered in ${renderingTime} ms`);

if (!existsSync(file)) {
mkdirSync(
resolve(
__dirname,
`../../benchmark-results/${testInfo.project.name}`,
),
{
recursive: true,
},
const file = resolve(
__dirname,
`../../benchmark-results/${testInfo.project.name}/ad-rendering-time-${testInfo.workerIndex}.txt`,
);
}

await appendFile(file, String(renderingTime) + '\n');
});
if (!existsSync(file)) {
mkdirSync(
resolve(
__dirname,
`../../benchmark-results/${testInfo.project.name}`,
),
{
recursive: true,
},
);
}

await appendFile(file, String(renderingTime) + '\n');
});
}
}
});
60 changes: 60 additions & 0 deletions playwright/fixtures/pages/load-time-pages.ts
Original file line number Diff line number Diff line change
@@ -124,6 +124,66 @@ const loadTimePages: GuPage[] = [
path: '/technology/2024/apr/30/amazon-sales-report-ai',
}),
},
{
path: getTestUrl({
stage,
path: '/film/article/2024/jun/06/show-me-the-money-how-unofficial-merch-is-cashing-in-on-movie-quotes',
}),
},
{
path: getTestUrl({
stage,
path: '/sport/article/2024/jun/05/family-mum-of-three-helen-glover-2024-olympics-paris-rowing-team-gb',
}),
},
{
path: getTestUrl({
stage,
path: '/travel/article/2024/may/26/how-to-keep-your-cool-cycling-up-italian-mountains-with-a-teenager-in-tow',
}),
},
{
path: getTestUrl({
stage,
path: '/environment/article/2024/may/23/fishing-barbara-creecy-minister-court-south-african-penguins-facing-extinction',
}),
},
{
path: getTestUrl({
stage,
path: '/travel/article/2024/jun/05/sailing-voyage-the-wash-norfolk-potatoes-chip-shop-kings-lynn',
}),
},
{
path: getTestUrl({
stage,
path: '/food/2024/apr/09/swapping-red-meat-for-herring-sardines-and-anchovies-could-save-75000-lives-study-suggests',
}),
},
{
path: getTestUrl({
stage,
path: '/science/article/2024/jun/05/carbon-detected-in-galaxy-observed-350m-years-after-big-bang',
}),
},
{
path: getTestUrl({
stage,
path: '/commentisfree/article/2024/jun/06/undecided-voters-british-politics-vote-election',
}),
},
{
path: getTestUrl({
stage,
path: '/lifeandstyle/article/2024/may/31/t26-surprisingly-useful-gadgets-you-didnt-know-you-needed',
}),
},
{
path: getTestUrl({
stage,
path: '/books/ng-interactive/2024/jun/05/this-months-best-paperbacks-zadie-smith-matthew-perry-and-more',
}),
},
];

export { loadTimePages };