Skip to content

Commit 071501c

Browse files
committed
finished using puppeteer for memory benchmark
1 parent a676404 commit 071501c

File tree

12 files changed

+2867
-3137
lines changed

12 files changed

+2867
-3137
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ After that you can check all results in [http://localhost:8080/webdriver-ts/tabl
221221
- You can select multiple frameworks and benchmarks for running with prefixes like in the following example in the webdriver-ts directory:
222222
`npm run bench -- --benchmark 01_ 02_ --framework keyed/vanillajs keyed/react-hooks`
223223
runs the test for all frameworks that contain either angular or bob, which means all angular versions and bobril and all benchmarks whose id contain 01* or 02*
224+
- The memory benchmarks assume certain paths for the chrome installation. If it doesn't fit use
225+
`npm run bench -- --chromeBinary /usr/bin/google-chrome`
224226
- If you can't get one framework to compile or run, just move it out of the frameworks directory and re-run
225227
- One can check whether an implementation is keyed or non-keyed via `npm run isKeyed` in the webdriver-ts directory. You can limit which frameworks to check in the same way as the webdriver test runner like e.g. `npm run isKeyed keyed/svelte`. The program will report an error if a benchmark implementation is incorrectly classified.
226228

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"results": "cd webdriver-ts && npm run results",
1313
"bench-all": "cd webdriver-ts && npm run bench && npm run results",
1414
"selenium": "cd webdriver-ts && npm run bench && npm run results",
15-
"install-webdriver-ts": "cd webdriver-ts && npm install",
15+
"install-webdriver-ts": "cd webdriver-ts && npm install && npm run compile",
1616
"install-webdriver-ts-results": "cd webdriver-ts-results && npm install",
1717
"install-local": "npm run install-webdriver-ts && npm run install-webdriver-ts-results",
1818
"docker-build-image": "docker build -t js-framework-benchmark-ubuntu -f Dockerfile .",

webdriver-ts-results/src/results.ts

Lines changed: 2753 additions & 2753 deletions
Large diffs are not rendered by default.

webdriver-ts-results/src/tables/MemResultsTable.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ const MemResultsTable = ({data, currentSortKey, sortBy}: {data: ResultTableData;
88
return (resultsMEM.results.length===0 ? null :
99
(<div>
1010
<h3>Memory allocation in MBs ± 95% confidence interval</h3>
11-
<p>Please note that currently issue <a href="https://github.com/krausest/js-framework-benchmark/issues/916">#916</a> causes wrong values for some frameworks.
12-
</p>
1311
<table className='results'>
1412
<thead>
1513
<tr>

webdriver-ts-results/table.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

webdriver-ts/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
8-
"bench": "cross-env LANG=\"en_US.UTF-8\" ts-node src/benchmarkRunner.ts",
8+
"tsbench": "cross-env LANG=\"en_US.UTF-8\" ts-node src/benchmarkRunner.ts",
9+
"bench": "cross-env LANG=\"en_US.UTF-8\" node dist/benchmarkRunner.js",
10+
"compile": "tsc",
911
"results": "ts-node src/createResultJS.ts && cd .. && cd webdriver-ts-results && npm run build-prod",
1012
"index": "ts-node src/createIndex.ts",
1113
"isKeyed": "cross-env LANG=\"en_US.UTF-8\" ts-node src/isKeyed.ts"

webdriver-ts/results.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

webdriver-ts/src/benchmarkRunner.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function forkAndCallBenchmark(
1414
): Promise<ErrorAndWarning> {
1515
return new Promise((resolve, reject) => {
1616
const forked = fork(
17-
benchmark.type == BenchmarkType.MEM ? "src/forkedBenchmarkRunnerPuppeteer.ts" : "src/forkedBenchmarkRunnerWebdriver.ts"
17+
benchmark.type == BenchmarkType.MEM ? "dist/forkedBenchmarkRunnerPuppeteer.js" : "dist/forkedBenchmarkRunnerWebdriver.js"
1818
);
1919
if (config.LOG_DETAILS) console.log("FORKING: forked child process");
2020
forked.send({
@@ -185,12 +185,13 @@ async function runBench(runFrameworks: FrameworkData[], benchmarkNames: string[]
185185

186186
let args: any = yargs(process.argv)
187187
.usage(
188-
"$0 [--framework Framework1 Framework2 ...] [--benchmark Benchmark1 Benchmark2 ...] [--count n] [--exitOnError] \n or: $0 [directory1] [directory2] .. [directory3] \n or: $0 installed"
188+
"$0 [--framework Framework1 Framework2 ...] [--benchmark Benchmark1 Benchmark2 ...] [--chromeBinary path] \n or: $0 [directory1] [directory2] .. [directory3]"
189189
)
190190
.help("help")
191191
.default("headless", false)
192192
.array("framework")
193-
.array("benchmark").argv;
193+
.array("benchmark")
194+
.string("chromeBinary").argv;
194195

195196
let allArgs = args._.length <= 2 ? [] : args._.slice(2, args._.length);
196197
let frameworkArgument = !args.framework ? allArgs : args.framework;

webdriver-ts/src/benchmarksPuppeteer.ts

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,7 @@
33
import { Browser, Page } from "puppeteer-core";
44
import { BenchmarkInfo, BenchmarkType } from "./benchmarksGeneric";
55
import { config, FrameworkData } from "./common";
6-
import {
7-
clickElementById,
8-
clickElementByXPath,
9-
waitForClassContained,
10-
waitForElementLocatedById,
11-
waitForElementLocatedByXpath,
12-
waitForElementNotLocatedByXPath,
13-
waitForTextContains,
14-
} from "./puppeteerAccess";
6+
import { clickElementById, waitForElement, waitForElementNotLocatedByXPath, waitForTextContains } from "./puppeteerAccess";
157

168
const BENCHMARK_21 = "21_ready-memory";
179
const BENCHMARK_22 = "22_run-memory";
@@ -20,8 +12,6 @@ const BENCHMARK_24 = "24_run5-memory";
2012
const BENCHMARK_25 = "25_run-clear-memory";
2113
const BENCHMARK_31 = "31_startup-ci";
2214

23-
type TBenchmarkID = typeof BENCHMARK_21 | typeof BENCHMARK_22 | typeof BENCHMARK_23 | typeof BENCHMARK_25 | typeof BENCHMARK_31;
24-
2515
export abstract class BenchmarkPuppeteer {
2616
id: string;
2717
type: BenchmarkType;
@@ -63,15 +53,10 @@ const benchReadyMemory = new (class extends BenchmarkPuppeteer {
6353
});
6454
}
6555
async init(page: Page) {
66-
await waitForElementLocatedById(page, "add", true);
67-
}
68-
async run(page: Page) {
69-
await waitForElementNotLocatedByXPath(page, "//tbody/tr[1]", false);
70-
}
71-
async after(page: Page, framework: FrameworkData) {
72-
await clickElementById(page, "run", true);
73-
await waitForElementLocatedByXpath(page, "//tbody/tr[1]/td[2]/a", false);
56+
await waitForElement(page, "pierce/#run");
7457
}
58+
async run(page: Page) {}
59+
async after(page: Page, framework: FrameworkData) {}
7560
})();
7661

7762
const benchRunMemory = new (class extends BenchmarkPuppeteer {
@@ -85,11 +70,11 @@ const benchRunMemory = new (class extends BenchmarkPuppeteer {
8570
});
8671
}
8772
async init(page: Page) {
88-
await waitForElementLocatedById(page, "add", true);
73+
await waitForElement(page, "pierce/#run");
8974
}
9075
async run(page: Page) {
91-
await clickElementById(page, "run", true);
92-
await waitForElementLocatedByXpath(page, "//tbody/tr[1]/td[2]/a", false);
76+
await clickElementById(page, "pierce/#run");
77+
await waitForElement(page, "pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(2)>a");
9378
}
9479
})();
9580

@@ -104,13 +89,13 @@ const benchUpdate5Memory = new (class extends BenchmarkPuppeteer {
10489
});
10590
}
10691
async init(page: Page) {
107-
await waitForElementLocatedById(page, "add", true);
92+
await waitForElement(page, "pierce/#run");
10893
}
10994
async run(page: Page) {
110-
await clickElementById(page, "run", true);
95+
await clickElementById(page, "pierce/#run");
11196
for (let i = 0; i < 5; i++) {
112-
await clickElementById(page, "update", true);
113-
await waitForTextContains(page, "//tbody/tr[1]/td[2]/a", " !!!".repeat(i), false);
97+
await clickElementById(page, "pierce/#update");
98+
await waitForTextContains(page, "pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(2)>a", " !!!".repeat(i));
11499
}
115100
}
116101
})();
@@ -126,12 +111,12 @@ const benchReplace5Memory = new (class extends BenchmarkPuppeteer {
126111
});
127112
}
128113
async init(page: Page) {
129-
await waitForElementLocatedById(page, "add", true);
114+
await waitForElement(page, "pierce/#run");
130115
}
131116
async run(page: Page) {
132117
for (let i = 0; i < 5; i++) {
133-
await clickElementById(page, "run", true);
134-
await waitForTextContains(page, "//tbody/tr[1000]/td[1]", (1000 * (i + 1)).toFixed(), false);
118+
await clickElementById(page, "pierce/#run");
119+
await waitForTextContains(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)", (1000 * (i + 1)).toFixed());
135120
}
136121
}
137122
})();
@@ -147,14 +132,14 @@ const benchCreateClear5Memory = new (class extends BenchmarkPuppeteer {
147132
});
148133
}
149134
async init(page: Page) {
150-
await waitForElementLocatedById(page, "add", true);
135+
await waitForElement(page, "pierce/#run");
151136
}
152137
async run(page: Page) {
153138
for (let i = 0; i < 5; i++) {
154-
await clickElementById(page, "run", true);
155-
await waitForTextContains(page, "//tbody/tr[1000]/td[1]", (1000 * (i + 1)).toFixed(), false);
156-
await clickElementById(page, "clear", true);
157-
await waitForElementNotLocatedByXPath(page, "//tbody/tr[1000]/td[1]", false);
139+
await clickElementById(page, "pierce/#run");
140+
await waitForTextContains(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)", (1000 * (i + 1)).toFixed());
141+
await clickElementById(page, "pierce/#clear");
142+
await waitForElementNotLocatedByXPath(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
158143
}
159144
}
160145
})();

0 commit comments

Comments
 (0)