Skip to content

Commit 5868ab9

Browse files
committed
use HeapProfiler.collectGarbage and resotre some browser flags
1 parent c5660d9 commit 5868ab9

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

webdriver-ts/src/forkedBenchmarkRunnerPuppeteer.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ function convertError(error: any): string {
5050
}
5151

5252
// eslint-disable-next-line @typescript-eslint/no-unused-vars
53-
async function forceGC(page: Page) {
53+
async function forceGC(page: Page, client: CDPSession) {
5454
for (let i = 0; i < 7; i++) {
55-
// await client.send('HeapProfiler.collectGarbage');
55+
await client.send("HeapProfiler.collectGarbage");
5656
await page.evaluate("window.gc()");
5757
}
5858
}
@@ -111,6 +111,7 @@ async function runCPUBenchmark(
111111
"devtools.timeline",
112112
"disabled-by-default-devtools.timeline",
113113
];
114+
const client = await page.createCDPSession();
114115

115116
// let categories = [
116117
// "-*", // exclude default
@@ -142,7 +143,7 @@ async function runCPUBenchmark(
142143
await wait(50);
143144
await puppeteerWait();
144145

145-
await forceGC(page);
146+
await forceGC(page, client);
146147
await puppeteerWait();
147148

148149
console.log("runBenchmark");
@@ -251,11 +252,11 @@ async function runMemBenchmark(
251252
// });
252253
console.log("initBenchmark");
253254
await initBenchmark(page, benchmark, framework);
254-
const client = await page.target().createCDPSession();
255+
const client = await page.createCDPSession();
255256

256257
console.log("runBenchmark");
257258
await runBenchmark(page, benchmark, framework);
258-
await forceGC(page);
259+
await forceGC(page, client);
259260
await wait(40);
260261
let result = ((await page.evaluate("performance.measureUserAgentSpecificMemory()")) as any).bytes / 1024 / 1024;
261262
console.log("afterBenchmark");

webdriver-ts/src/puppeteerAccess.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ export async function startBrowser(benchmarkOptions: BenchmarkOptions): Promise<
113113
`--window-size=${window_width},${window_height}`,
114114
"--js-flags=--expose-gc",
115115
"--no-default-browser-check",
116+
"--disable-sync",
117+
"--no-first-run",
118+
"--disable-extensions",
119+
"--disable-features=Translate",
116120
"--disable-features=PrivacySandboxSettings4",
117121
];
118122
if (benchmarkOptions.headless) args.push("--headless=new");

0 commit comments

Comments
 (0)