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

feat: add page.emulateCPUThrottling #7343

Merged
merged 5 commits into from
Jun 22, 2021
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
Prev Previous commit
Next Next commit
chore: remove measuring due to flakiness
jschfflr committed Jun 22, 2021
commit 67ee5e18ef93406918f4f59ad988d225820349ae
21 changes: 0 additions & 21 deletions test/emulation.spec.ts
Original file line number Diff line number Diff line change
@@ -413,29 +413,8 @@ describe('Emulation', () => {
it('should slow down execution', async () => {
const { page } = getTestState();

async function measure() {
const start = new Date();
await page.evaluate(() => {
let i = 0;
while (i < 1000) {
i++;
}
});

const end = new Date();
return +end - +start;
}

const baseline = await measure();
await page.emulateCPUThrottling(100);
OrKoN marked this conversation as resolved.
Show resolved Hide resolved
const throttledTime = await measure();
await page.emulateCPUThrottling(null);
const timeWithoutThrottle = await measure();

// Throttling is not super precise. 20 has been chosen as very loose
// threshold just to make sure that throttling has at least _some_ effect.
expect(throttledTime / baseline).toBeGreaterThan(20);
expect(timeWithoutThrottle / baseline).toBeLessThan(20);
});
});
});