Skip to content

Commit f3e264f

Browse files
committed
Derive checks from config.WARMUP_COUNT
1 parent 9189205 commit f3e264f

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

webdriver-ts/src/benchmarksPuppeteer.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const benchReplaceAll = new (class extends CPUBenchmarkPuppeteer {
6868
}
6969
async run(page: Page) {
7070
await clickElement(page, "pierce/#run");
71-
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)", "5001");
71+
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)", `${config.WARMUP_COUNT * 1000 + 1}`);
7272
}
7373
})();
7474

@@ -127,35 +127,39 @@ export const benchSwapRows = new (class extends CPUBenchmarkPuppeteer {
127127
}
128128
async run(page: Page) {
129129
await clickElement(page, "pierce/#swaprows");
130-
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(999)>td:nth-of-type(1)", "2");
131-
await checkElementContainsText(page, "pierce/tbody>tr:nth-of-type(2)>td:nth-of-type(1)", "999");
130+
let text999 = config.WARMUP_COUNT % 2 == 0 ? "999" : "2";
131+
let text2 = config.WARMUP_COUNT % 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);
132134
}
133135
})();
134136

135137
export const benchRemove = new (class extends CPUBenchmarkPuppeteer {
136138
constructor() {
137139
super(cpuBenchmarkInfos[Benchmark._06]);
138140
}
141+
rowsToSkip = 4;
139142
async init(page: Page) {
140143
await checkElementExists(page, "pierce/#run");
141144
await clickElement(page, "pierce/#run");
142145
await checkElementExists(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
143146
for (let i = 0; i < config.WARMUP_COUNT; i++) {
144-
await checkElementContainsText(page, `pierce/tbody>tr:nth-of-type(${config.WARMUP_COUNT - i + 4})>td:nth-of-type(1)`, (config.WARMUP_COUNT - i + 4).toString());
145-
await clickElement(page, `pierce/tbody>tr:nth-of-type(${config.WARMUP_COUNT - i + 4})>td:nth-of-type(3)>a>span:nth-of-type(1)`);
146-
await checkElementContainsText(page, `pierce/tbody>tr:nth-of-type(${config.WARMUP_COUNT - i + 4})>td:nth-of-type(1)`, "10");
147+
const rowToClick = config.WARMUP_COUNT - 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 + config.WARMUP_COUNT + 1}`);
147151
}
148-
await checkElementContainsText(page, `pierce/tbody>tr:nth-of-type(5)>td:nth-of-type(1)`, "10");
149-
await checkElementContainsText(page, `pierce/tbody>tr:nth-of-type(4)>td:nth-of-type(1)`, "4");
152+
await checkElementContainsText(page, `pierce/tbody>tr:nth-of-type(${this.rowsToSkip + 1})>td:nth-of-type(1)`, `${this.rowsToSkip + config.WARMUP_COUNT + 1}`);
153+
await checkElementContainsText(page, `pierce/tbody>tr:nth-of-type(${this.rowsToSkip})>td:nth-of-type(1)`, `${this.rowsToSkip}`);
150154

151155
// Click on a row the second time
152-
await checkElementContainsText(page, `pierce/tbody>tr:nth-of-type(6)>td:nth-of-type(1)`, "11");
153-
await clickElement(page, `pierce/tbody>tr:nth-of-type(6)>td:nth-of-type(3)>a>span:nth-of-type(1)`);
154-
await checkElementContainsText(page, `pierce/tbody>tr:nth-of-type(6)>td:nth-of-type(1)`, "12");
156+
await checkElementContainsText(page, `pierce/tbody>tr:nth-of-type(${this.rowsToSkip + 2})>td:nth-of-type(1)`, `${this.rowsToSkip + config.WARMUP_COUNT + 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 + config.WARMUP_COUNT + 3}`);
155159
}
156160
async run(page: Page) {
157-
await clickElement(page, `pierce/tbody>tr:nth-of-type(4)>td:nth-of-type(3)>a>span:nth-of-type(1)`);
158-
await checkElementContainsText(page, `pierce/tbody>tr:nth-of-type(4)>td:nth-of-type(1)`, "10");
161+
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 + config.WARMUP_COUNT + 1}`);
159163
}
160164
})();
161165
export const benchRunBig = new (class extends CPUBenchmarkPuppeteer {

0 commit comments

Comments
 (0)