Skip to content

Commit 408c8af

Browse files
committed
Merge branch 'master' of github.com:krausest/js-framework-benchmark
2 parents a6c5b5f + a92354a commit 408c8af

File tree

6 files changed

+172
-169
lines changed

6 files changed

+172
-169
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ target/
4343
webdriver-ts/results/
4444
webdriver-ts/traces/
4545
webdriver-ts/results*/
46+
webdriver-ts/traces*/
4647
webdriver-ts/old_results/
4748
webdriver-ts-results/table_*.html
4849
webdriver-ts/table_*.html

webdriver-ts/src/benchmarkConfiguration.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import * as benchmarksWebdriver from "./benchmarksWebdriver";
44
import * as benchmarksWebdriverCDP from "./benchmarksWebdriverCDP";
55
import * as benchmarksLighthouse from "./benchmarksLighthouse";
66

7-
export type TBenchmark = benchmarksWebdriver.CPUBenchmarkWebdriver | benchmarksPuppeteer.TBenchmarkPuppeteer
8-
| benchmarksLighthouse.BenchmarkLighthouse | benchmarksPlaywright.CPUBenchmarkPlaywright | benchmarksWebdriverCDP.CPUBenchmarkWebdriverCDP;
7+
export type TBenchmarkImplementation = benchmarksWebdriver.CPUBenchmarkWebdriver | benchmarksPuppeteer.TBenchmarkPuppeteer
8+
| benchmarksLighthouse.BenchmarkLighthouse
9+
| benchmarksPlaywright.CPUBenchmarkPlaywright | benchmarksPlaywright.MemBenchmarkPlaywright
10+
| benchmarksWebdriverCDP.CPUBenchmarkWebdriverCDP;
911

10-
export const benchmarks: Array<TBenchmark> = [
12+
export const benchmarks: Array<TBenchmarkImplementation> = [
1113
benchmarksPuppeteer.benchRun,
1214
benchmarksPuppeteer.benchReplaceAll,
1315
benchmarksPuppeteer.benchUpdate,

webdriver-ts/src/benchmarkRunner.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { fork } from "child_process";
22
import * as fs from "fs";
33
import * as yargs from "yargs";
4-
import { BenchmarkInfo, BenchmarkType } from "./benchmarksCommon";
4+
import { BenchmarkInfo, BenchmarkType, TBenchmark } from "./benchmarksCommon";
55
import { CPUBenchmarkPuppeteer, MemBenchmarkPuppeteer, TBenchmarkPuppeteer } from "./benchmarksPuppeteer";
6-
import { CPUBenchmarkPlaywright, TBenchmarkPlaywright } from "./benchmarksPlaywright";
6+
import { CPUBenchmarkPlaywright, MemBenchmarkPlaywright, TBenchmarkPlaywright } from "./benchmarksPlaywright";
77
import { CPUBenchmarkWebdriver } from "./benchmarksWebdriver";
88
import { BenchmarkDriverOptions, BenchmarkOptions, config, ErrorAndWarning, FrameworkData, initializeFrameworks } from "./common";
99
import { writeResults } from "./writeResults";
10-
import {benchmarks} from "./benchmarkConfiguration";
10+
import {benchmarks, TBenchmarkImplementation} from "./benchmarkConfiguration";
1111
import { BenchmarkLighthouse, StartupBenchmarkResult } from "./benchmarksLighthouse";
1212
import { CPUBenchmarkWebdriverCDP } from "./benchmarksWebdriverCDP";
1313

@@ -22,7 +22,7 @@ function forkAndCallBenchmark(
2222
forkedRunner = "dist/forkedBenchmarkRunnerLighthouse.js";
2323
} else if (benchmark instanceof CPUBenchmarkWebdriverCDP) {
2424
forkedRunner = "dist/forkedBenchmarkRunnerWebdriverCDP.js";
25-
} else if (benchmark instanceof CPUBenchmarkPlaywright /*|| benchmark instanceof MemBenchmarkPuppeteer*/) {
25+
} else if (benchmark instanceof CPUBenchmarkPlaywright || benchmark instanceof MemBenchmarkPlaywright) {
2626
forkedRunner = "dist/forkedBenchmarkRunnerPlaywright.js";
2727
} else if (benchmark instanceof CPUBenchmarkPuppeteer || benchmark instanceof MemBenchmarkPuppeteer) {
2828
forkedRunner = "dist/forkedBenchmarkRunnerPuppeteer.js";
@@ -170,7 +170,7 @@ async function runBench(runFrameworks: FrameworkData[], benchmarkNames: string[]
170170
let errors: String[] = [];
171171
let warnings: String[] = [];
172172

173-
let runBenchmarks: Array<CPUBenchmarkWebdriver | TBenchmarkPuppeteer | BenchmarkLighthouse | CPUBenchmarkPlaywright> = benchmarks.filter((b) =>
173+
let runBenchmarks: Array<TBenchmarkImplementation> = benchmarks.filter((b) =>
174174
benchmarkNames.some((name) => b.benchmarkInfo.id.toLowerCase().indexOf(name) > -1)
175175
);
176176

webdriver-ts/src/benchmarksPlaywright.ts

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -267,102 +267,102 @@ export const benchClear = new class extends CPUBenchmarkPlaywright {
267267
}
268268
}
269269

270-
// export const benchReadyMemory = new (class extends MemBenchmarkPlaywright {
271-
// constructor() {
272-
// super({
273-
// id: benchmarksCommon.BENCHMARK_21,
274-
// label: "ready memory",
275-
// description: "Memory usage after page load.",
276-
// type: BenchmarkType.MEM,
277-
// });
278-
// }
279-
// async init(browser: Browser, page: Page) {
280-
// await checkElementExists(page, "pierce/#run");
281-
// }
282-
// async run(browser: Browser, page: Page) {}
283-
// async after(page: Page, framework: FrameworkData) {}
284-
// })();
270+
export const benchReadyMemory = new (class extends MemBenchmarkPlaywright {
271+
constructor() {
272+
super({
273+
id: benchmarksCommon.BENCHMARK_21,
274+
label: "ready memory",
275+
description: "Memory usage after page load.",
276+
type: BenchmarkType.MEM,
277+
});
278+
}
279+
async init(browser: Browser, page: Page) {
280+
await checkElementExists(page, "#run");
281+
}
282+
async run(browser: Browser, page: Page) {}
283+
async after(page: Page, framework: FrameworkData) {}
284+
})();
285285

286-
// export const benchRunMemory = new (class extends MemBenchmarkPlaywright {
287-
// constructor() {
288-
// super({
289-
// id: benchmarksCommon.BENCHMARK_22,
290-
// label: "run memory",
291-
// description: "Memory usage after adding 1000 rows.",
292-
// type: BenchmarkType.MEM,
293-
// });
294-
// }
295-
// async init(browser: Browser, page: Page) {
296-
// await checkElementExists(page, "pierce/#run");
297-
// }
298-
// async run(browser: Browser, page: Page) {
299-
// await clickElement(page, "pierce/#run");
300-
// await checkElementExists(page, "pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(2)>a");
301-
// }
302-
// })();
286+
export const benchRunMemory = new (class extends MemBenchmarkPlaywright {
287+
constructor() {
288+
super({
289+
id: benchmarksCommon.BENCHMARK_22,
290+
label: "run memory",
291+
description: "Memory usage after adding 1000 rows.",
292+
type: BenchmarkType.MEM,
293+
});
294+
}
295+
async init(browser: Browser, page: Page) {
296+
await checkElementExists(page, "#run");
297+
}
298+
async run(browser: Browser, page: Page) {
299+
await clickElement(page, "#run");
300+
await checkElementExists(page, "tbody>tr:nth-of-type(1)>td:nth-of-type(2)>a");
301+
}
302+
})();
303303

304-
// export const benchUpdate5Memory = new (class extends MemBenchmarkPlaywright {
305-
// constructor() {
306-
// super({
307-
// id: benchmarksCommon.BENCHMARK_23,
308-
// label: "update every 10th row for 1k rows (5 cycles)",
309-
// description: "Memory usage after clicking update every 10th row 5 times",
310-
// type: BenchmarkType.MEM,
311-
// });
312-
// }
313-
// async init(browser: Browser, page: Page) {
314-
// await checkElementExists(page, "pierce/#run");
315-
// }
316-
// async run(browser: Browser, page: Page) {
317-
// await clickElement(page, "pierce/#run");
318-
// for (let i = 0; i < 5; i++) {
319-
// await clickElement(page, "pierce/#update");
320-
// await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(2)>a", " !!!".repeat(i));
321-
// }
322-
// }
323-
// })();
304+
export const benchUpdate5Memory = new (class extends MemBenchmarkPlaywright {
305+
constructor() {
306+
super({
307+
id: benchmarksCommon.BENCHMARK_23,
308+
label: "update every 10th row for 1k rows (5 cycles)",
309+
description: "Memory usage after clicking update every 10th row 5 times",
310+
type: BenchmarkType.MEM,
311+
});
312+
}
313+
async init(browser: Browser, page: Page) {
314+
await checkElementExists(page, "#run");
315+
}
316+
async run(browser: Browser, page: Page) {
317+
await clickElement(page, "#run");
318+
for (let i = 0; i < 5; i++) {
319+
await clickElement(page, "#update");
320+
await checkElementContainsText(page, "tbody>tr:nth-of-type(1)>td:nth-of-type(2)>a", " !!!".repeat(i));
321+
}
322+
}
323+
})();
324324

325-
// export const benchReplace5Memory = new (class extends MemBenchmarkPlaywright {
326-
// constructor() {
327-
// super({
328-
// id: benchmarksCommon.BENCHMARK_24,
329-
// label: "replace 1k rows (5 cycles)",
330-
// description: "Memory usage after clicking create 1000 rows 5 times",
331-
// type: BenchmarkType.MEM,
332-
// });
333-
// }
334-
// async init(browser: Browser, page: Page) {
335-
// await checkElementExists(page, "pierce/#run");
336-
// }
337-
// async run(browser: Browser, page: Page) {
338-
// for (let i = 0; i < 5; i++) {
339-
// await clickElement(page, "pierce/#run");
340-
// await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)", (1000 * (i + 1)).toFixed());
341-
// }
342-
// }
343-
// })();
325+
export const benchReplace5Memory = new (class extends MemBenchmarkPlaywright {
326+
constructor() {
327+
super({
328+
id: benchmarksCommon.BENCHMARK_24,
329+
label: "replace 1k rows (5 cycles)",
330+
description: "Memory usage after clicking create 1000 rows 5 times",
331+
type: BenchmarkType.MEM,
332+
});
333+
}
334+
async init(browser: Browser, page: Page) {
335+
await checkElementExists(page, "#run");
336+
}
337+
async run(browser: Browser, page: Page) {
338+
for (let i = 0; i < 5; i++) {
339+
await clickElement(page, "#run");
340+
await checkElementContainsText(page, "tbody>tr:nth-of-type(1000)>td:nth-of-type(1)", (1000 * (i + 1)).toFixed());
341+
}
342+
}
343+
})();
344344

345-
// export const benchCreateClear5Memory = new (class extends MemBenchmarkPlaywright {
346-
// constructor() {
347-
// super({
348-
// id: benchmarksCommon.BENCHMARK_25,
349-
// label: "creating/clearing 1k rows (5 cycles)",
350-
// description: "Memory usage after creating and clearing 1000 rows 5 times",
351-
// type: BenchmarkType.MEM,
352-
// });
353-
// }
354-
// async init(browser: Browser, page: Page) {
355-
// await checkElementExists(page, "pierce/#run");
356-
// }
357-
// async run(browser: Browser, page: Page) {
358-
// for (let i = 0; i < 5; i++) {
359-
// await clickElement(page, "pierce/#run");
360-
// await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)", (1000 * (i + 1)).toFixed());
361-
// await clickElement(page, "pierce/#clear");
362-
// await checkElementNotExists(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
363-
// }
364-
// }
365-
// })();
345+
export const benchCreateClear5Memory = new (class extends MemBenchmarkPlaywright {
346+
constructor() {
347+
super({
348+
id: benchmarksCommon.BENCHMARK_25,
349+
label: "creating/clearing 1k rows (5 cycles)",
350+
description: "Memory usage after creating and clearing 1000 rows 5 times",
351+
type: BenchmarkType.MEM,
352+
});
353+
}
354+
async init(browser: Browser, page: Page) {
355+
await checkElementExists(page, "#run");
356+
}
357+
async run(browser: Browser, page: Page) {
358+
for (let i = 0; i < 5; i++) {
359+
await clickElement(page, "#run");
360+
await checkElementContainsText(page, "tbody>tr:nth-of-type(1000)>td:nth-of-type(1)", (1000 * (i + 1)).toFixed());
361+
await clickElement(page, "#clear");
362+
await checkElementNotExists(page, "tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
363+
}
364+
}
365+
})();
366366

367367

368368
export function fileNameTrace(framework: FrameworkData, benchmark: TBenchmark, run: number) {

0 commit comments

Comments
 (0)