Skip to content

Commit 81d6f9e

Browse files
committed
first fix for chrome 104
1 parent 30c247a commit 81d6f9e

File tree

4 files changed

+235
-97
lines changed

4 files changed

+235
-97
lines changed

webdriver-ts/src/benchmarksPuppeteer.ts

Lines changed: 143 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
BenchmarkImpl,
1111
MemBenchmarkInfo,
1212
} from "./benchmarksCommon.js";
13-
import { config, FrameworkData } from "./common.js";
13+
import { config, FrameworkData, puppeteerWait } from "./common.js";
1414
import {
1515
checkCountForSelector,
1616
checkElementContainsText,
@@ -40,18 +40,28 @@ export let benchRun = new (class extends CPUBenchmarkPuppeteer {
4040
constructor() {
4141
super(cpuBenchmarkInfos[Benchmark._01]);
4242
}
43-
async init(page: Page) {
43+
async init(page: Page) {
4444
await checkElementExists(page, "pierce/#run");
4545
for (let i = 0; i < this.benchmarkInfo.warmupCount; i++) {
46+
await puppeteerWait();
4647
await clickElement(page, "pierce/#run");
47-
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)", (i*1000+1).toFixed());
48+
await checkElementContainsText(
49+
page,
50+
"pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)",
51+
(i * 1000 + 1).toFixed()
52+
);
53+
await puppeteerWait();
4854
await clickElement(page, "pierce/#clear");
4955
await checkElementNotExists(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
5056
}
5157
}
5258
async run(page: Page) {
53-
await clickElement(page, "pierce/#run");
54-
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)", ((this.benchmarkInfo.warmupCount+1)*1000).toFixed());
59+
await clickElement(page, "pierce/#run");
60+
await checkElementContainsText(
61+
page,
62+
"pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)",
63+
((this.benchmarkInfo.warmupCount + 1) * 1000).toFixed()
64+
);
5565
}
5666
})();
5767

@@ -60,15 +70,23 @@ export const benchReplaceAll = new (class extends CPUBenchmarkPuppeteer {
6070
super(cpuBenchmarkInfos[Benchmark._02]);
6171
}
6272
async init(page: Page) {
63-
await checkElementExists(page, "pierce/#run");
64-
for (let i = 0; i < this.benchmarkInfo.warmupCount; i++) {
65-
await clickElement(page, "pierce/#run");
66-
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)", (i*1000+1).toFixed());
67-
}
73+
await checkElementExists(page, "pierce/#run");
74+
for (let i = 0; i < this.benchmarkInfo.warmupCount; i++) {
75+
await clickElement(page, "pierce/#run");
76+
await checkElementContainsText(
77+
page,
78+
"pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)",
79+
(i * 1000 + 1).toFixed()
80+
);
81+
}
6882
}
6983
async run(page: Page) {
7084
await clickElement(page, "pierce/#run");
71-
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)", `${this.benchmarkInfo.warmupCount * 1000 + 1}`);
85+
await checkElementContainsText(
86+
page,
87+
"pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)",
88+
`${this.benchmarkInfo.warmupCount * 1000 + 1}`
89+
);
7290
}
7391
})();
7492

@@ -80,14 +98,22 @@ export const benchUpdate = new (class extends CPUBenchmarkPuppeteer {
8098
await checkElementExists(page, "pierce/#run");
8199
await clickElement(page, "pierce/#run");
82100
await checkElementExists(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
83-
for (let i = 0; i < this.benchmarkInfo.warmupCount; i++) {
84-
await clickElement(page, "pierce/#update");
85-
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(991)>td:nth-of-type(2)>a", ' !!!'.repeat(i + 1));
86-
}
101+
for (let i = 0; i < this.benchmarkInfo.warmupCount; i++) {
102+
await clickElement(page, "pierce/#update");
103+
await checkElementContainsText(
104+
page,
105+
"pierce/tbody>tr:nth-of-type(991)>td:nth-of-type(2)>a",
106+
" !!!".repeat(i + 1)
107+
);
108+
}
87109
}
88110
async run(page: Page) {
89111
await clickElement(page, "pierce/#update");
90-
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(991)>td:nth-of-type(2)>a", ' !!!'.repeat(this.benchmarkInfo.warmupCount + 1));
112+
await checkElementContainsText(
113+
page,
114+
"pierce/tbody>tr:nth-of-type(991)>td:nth-of-type(2)>a",
115+
" !!!".repeat(this.benchmarkInfo.warmupCount + 1)
116+
);
91117
}
92118
})();
93119

@@ -106,8 +132,8 @@ export const benchSelect = new (class extends CPUBenchmarkPuppeteer {
106132
}
107133
}
108134
async run(page: Page) {
109-
await clickElement(page, "pierce/tbody>tr:nth-of-type(2)>td:nth-of-type(2)>a");
110-
await checkElementHasClass(page, "pierce/tbody>tr:nth-of-type(2)", "danger");
135+
await clickElement(page, "pierce/tbody>tr:nth-of-type(2)>td:nth-of-type(2)>a");
136+
await checkElementHasClass(page, "pierce/tbody>tr:nth-of-type(2)", "danger");
111137
}
112138
})();
113139

@@ -116,21 +142,21 @@ export const benchSwapRows = new (class extends CPUBenchmarkPuppeteer {
116142
super(cpuBenchmarkInfos[Benchmark._05]);
117143
}
118144
async init(page: Page) {
119-
await checkElementExists(page, "pierce/#run");
120-
await clickElement(page, "pierce/#run");
121-
await checkElementExists(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
122-
for (let i = 0; i <= this.benchmarkInfo.warmupCount; i++) {
123-
let text = i % 2 == 0 ? "2" : "999";
124-
await clickElement(page, "pierce/#swaprows");
125-
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(999)>td:nth-of-type(1)", text);
126-
}
145+
await checkElementExists(page, "pierce/#run");
146+
await clickElement(page, "pierce/#run");
147+
await checkElementExists(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
148+
for (let i = 0; i <= this.benchmarkInfo.warmupCount; i++) {
149+
let text = i % 2 == 0 ? "2" : "999";
150+
await clickElement(page, "pierce/#swaprows");
151+
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(999)>td:nth-of-type(1)", text);
152+
}
127153
}
128154
async run(page: Page) {
129-
await clickElement(page, "pierce/#swaprows");
130-
let text999 = this.benchmarkInfo.warmupCount % 2 == 0 ? "999" : "2";
131-
let text2 = this.benchmarkInfo.warmupCount % 2 == 0 ? "2" : "999";
132-
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(999)>td:nth-of-type(1)", text999);
133-
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(2)>td:nth-of-type(1)", text2);
155+
await clickElement(page, "pierce/#swaprows");
156+
let text999 = this.benchmarkInfo.warmupCount % 2 == 0 ? "999" : "2";
157+
let text2 = this.benchmarkInfo.warmupCount % 2 == 0 ? "2" : "999";
158+
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(999)>td:nth-of-type(1)", text999);
159+
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(2)>td:nth-of-type(1)", text2);
134160
}
135161
})();
136162

@@ -143,44 +169,79 @@ export const benchRemove = new (class extends CPUBenchmarkPuppeteer {
143169
await checkElementExists(page, "pierce/#run");
144170
await clickElement(page, "pierce/#run");
145171
await checkElementExists(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
146-
for (let i = 0; i < this.benchmarkInfo.warmupCount; i++) {
147-
const rowToClick = this.benchmarkInfo.warmupCount - i + this.rowsToSkip;
148-
await checkElementContainsText(page, `pierce/tbody>tr:nth-of-type(${rowToClick})>td:nth-of-type(1)`, rowToClick.toString());
149-
await clickElement(page, `pierce/tbody>tr:nth-of-type(${rowToClick})>td:nth-of-type(3)>a>span:nth-of-type(1)`);
150-
await checkElementContainsText(page, `pierce/tbody>tr:nth-of-type(${rowToClick})>td:nth-of-type(1)`, `${this.rowsToSkip + this.benchmarkInfo.warmupCount + 1}`);
151-
}
152-
await checkElementContainsText(page, `pierce/tbody>tr:nth-of-type(${this.rowsToSkip + 1})>td:nth-of-type(1)`, `${this.rowsToSkip + this.benchmarkInfo.warmupCount + 1}`);
153-
await checkElementContainsText(page, `pierce/tbody>tr:nth-of-type(${this.rowsToSkip})>td:nth-of-type(1)`, `${this.rowsToSkip}`);
172+
for (let i = 0; i < this.benchmarkInfo.warmupCount; i++) {
173+
const rowToClick = this.benchmarkInfo.warmupCount - i + this.rowsToSkip;
174+
await checkElementContainsText(
175+
page,
176+
`pierce/tbody>tr:nth-of-type(${rowToClick})>td:nth-of-type(1)`,
177+
rowToClick.toString()
178+
);
179+
await clickElement(page, `pierce/tbody>tr:nth-of-type(${rowToClick})>td:nth-of-type(3)>a>span:nth-of-type(1)`);
180+
await checkElementContainsText(
181+
page,
182+
`pierce/tbody>tr:nth-of-type(${rowToClick})>td:nth-of-type(1)`,
183+
`${this.rowsToSkip + this.benchmarkInfo.warmupCount + 1}`
184+
);
185+
}
186+
await checkElementContainsText(
187+
page,
188+
`pierce/tbody>tr:nth-of-type(${this.rowsToSkip + 1})>td:nth-of-type(1)`,
189+
`${this.rowsToSkip + this.benchmarkInfo.warmupCount + 1}`
190+
);
191+
await checkElementContainsText(
192+
page,
193+
`pierce/tbody>tr:nth-of-type(${this.rowsToSkip})>td:nth-of-type(1)`,
194+
`${this.rowsToSkip}`
195+
);
154196

155-
// Click on a row the second time
156-
await checkElementContainsText(page, `pierce/tbody>tr:nth-of-type(${this.rowsToSkip + 2})>td:nth-of-type(1)`, `${this.rowsToSkip + this.benchmarkInfo.warmupCount + 2}`);
157-
await clickElement(page, `pierce/tbody>tr:nth-of-type(${this.rowsToSkip + 2})>td:nth-of-type(3)>a>span:nth-of-type(1)`);
158-
await checkElementContainsText(page, `pierce/tbody>tr:nth-of-type(${this.rowsToSkip + 2})>td:nth-of-type(1)`, `${this.rowsToSkip + this.benchmarkInfo.warmupCount + 3}`);
197+
// Click on a row the second time
198+
await checkElementContainsText(
199+
page,
200+
`pierce/tbody>tr:nth-of-type(${this.rowsToSkip + 2})>td:nth-of-type(1)`,
201+
`${this.rowsToSkip + this.benchmarkInfo.warmupCount + 2}`
202+
);
203+
await clickElement(
204+
page,
205+
`pierce/tbody>tr:nth-of-type(${this.rowsToSkip + 2})>td:nth-of-type(3)>a>span:nth-of-type(1)`
206+
);
207+
await checkElementContainsText(
208+
page,
209+
`pierce/tbody>tr:nth-of-type(${this.rowsToSkip + 2})>td:nth-of-type(1)`,
210+
`${this.rowsToSkip + this.benchmarkInfo.warmupCount + 3}`
211+
);
159212
}
160213
async run(page: Page) {
161214
await clickElement(page, `pierce/tbody>tr:nth-of-type(${this.rowsToSkip})>td:nth-of-type(3)>a>span:nth-of-type(1)`);
162-
await checkElementContainsText(page, `pierce/tbody>tr:nth-of-type(${this.rowsToSkip})>td:nth-of-type(1)`, `${this.rowsToSkip + this.benchmarkInfo.warmupCount + 1}`);
215+
await checkElementContainsText(
216+
page,
217+
`pierce/tbody>tr:nth-of-type(${this.rowsToSkip})>td:nth-of-type(1)`,
218+
`${this.rowsToSkip + this.benchmarkInfo.warmupCount + 1}`
219+
);
163220
}
164221
})();
165222
export const benchRunBig = new (class extends CPUBenchmarkPuppeteer {
166223
constructor() {
167-
super(cpuBenchmarkInfos[Benchmark._07]);
224+
super(cpuBenchmarkInfos[Benchmark._07]);
168225
}
169226
async init(page: Page) {
170227
await checkElementExists(page, "pierce/#run");
171228
for (let i = 0; i < this.benchmarkInfo.warmupCount; i++) {
172229
await clickElement(page, "pierce/#run");
173-
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)", (i*1000+1).toFixed());
230+
await checkElementContainsText(
231+
page,
232+
"pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)",
233+
(i * 1000 + 1).toFixed()
234+
);
174235
await clickElement(page, "pierce/#clear");
175236
await checkElementNotExists(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
176-
}
237+
}
177238
}
178239
async run(page: Page) {
179240
await clickElement(page, "pierce/#runlots");
180241
await checkElementExists(page, "pierce/tbody>tr:nth-of-type(10000)>td:nth-of-type(2)>a");
181242
}
182243
})();
183-
244+
184245
export const benchAppendToManyRows = new (class extends CPUBenchmarkPuppeteer {
185246
constructor() {
186247
super(cpuBenchmarkInfos[Benchmark._08]);
@@ -189,10 +250,14 @@ export const benchAppendToManyRows = new (class extends CPUBenchmarkPuppeteer {
189250
await checkElementExists(page, "pierce/#run");
190251
for (let i = 0; i < this.benchmarkInfo.warmupCount; i++) {
191252
await clickElement(page, "pierce/#run");
192-
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)", (i*1000+1).toFixed());
253+
await checkElementContainsText(
254+
page,
255+
"pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)",
256+
(i * 1000 + 1).toFixed()
257+
);
193258
await clickElement(page, "pierce/#clear");
194259
await checkElementNotExists(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
195-
}
260+
}
196261
await clickElement(page, "pierce/#run");
197262
await checkElementExists(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
198263
}
@@ -210,16 +275,24 @@ export const benchClear = new (class extends CPUBenchmarkPuppeteer {
210275
await checkElementExists(page, "pierce/#run");
211276
for (let i = 0; i < this.benchmarkInfo.warmupCount; i++) {
212277
await clickElement(page, "pierce/#run");
213-
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)", (i*1000+1).toFixed());
278+
await checkElementContainsText(
279+
page,
280+
"pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)",
281+
(i * 1000 + 1).toFixed()
282+
);
214283
await clickElement(page, "pierce/#clear");
215284
await checkElementNotExists(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
216285
}
217286
await clickElement(page, "pierce/#run");
218-
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)", (this.benchmarkInfo.warmupCount*1000+1).toFixed());
287+
await checkElementContainsText(
288+
page,
289+
"pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)",
290+
(this.benchmarkInfo.warmupCount * 1000 + 1).toFixed()
291+
);
219292
}
220293
async run(page: Page) {
221-
await clickElement(page, "pierce/#clear");
222-
await checkElementNotExists(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
294+
await clickElement(page, "pierce/#clear");
295+
await checkElementNotExists(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
223296
}
224297
})();
225298

@@ -303,27 +376,31 @@ export const benchCreateClear5Memory = new (class extends MemBenchmarkPuppeteer
303376
async run(page: Page) {
304377
for (let i = 0; i < 5; i++) {
305378
await clickElement(page, "pierce/#run");
306-
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)", (1000 * (i + 1)).toFixed());
379+
await checkElementContainsText(
380+
page,
381+
"pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)",
382+
(1000 * (i + 1)).toFixed()
383+
);
307384
await clickElement(page, "pierce/#clear");
308385
await checkElementNotExists(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
309386
}
310387
}
311388
})();
312389

313390
export const benchmarks = [
314-
benchRun,
391+
benchRun,
315392
benchReplaceAll,
316-
benchUpdate,
317-
benchSelect,
318-
benchSwapRows,
319-
benchRemove,
320-
benchRunBig,
321-
benchAppendToManyRows,
322-
benchClear,
323-
benchReadyMemory,
324-
benchRunMemory,
393+
benchUpdate,
394+
benchSelect,
395+
benchSwapRows,
396+
benchRemove,
397+
benchRunBig,
398+
benchAppendToManyRows,
399+
benchClear,
400+
benchReadyMemory,
401+
benchRunMemory,
325402
benchUpdate5Memory,
326-
// benchReplace5Memory,
403+
// benchReplace5Memory,
327404
benchCreateClear5Memory,
328405
benchRun10KMemory,
329406
];

webdriver-ts/src/common.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,11 @@ export async function initializeFrameworks(
170170
}
171171
return frameworks;
172172
}
173+
174+
export const wait = (delay = 1000) => {
175+
console.log(`Waiting for ${delay} ms`);
176+
if (delay === 0) return Promise.resolve();
177+
else return new Promise((res) => setTimeout(res, delay));
178+
};
179+
180+
export const puppeteerWait = () => wait(1000);

0 commit comments

Comments
 (0)