@@ -10,7 +10,7 @@ import {
10
10
BenchmarkImpl ,
11
11
MemBenchmarkInfo ,
12
12
} from "./benchmarksCommon.js" ;
13
- import { config , FrameworkData } from "./common.js" ;
13
+ import { config , FrameworkData , puppeteerWait } from "./common.js" ;
14
14
import {
15
15
checkCountForSelector ,
16
16
checkElementContainsText ,
@@ -40,18 +40,28 @@ export let benchRun = new (class extends CPUBenchmarkPuppeteer {
40
40
constructor ( ) {
41
41
super ( cpuBenchmarkInfos [ Benchmark . _01 ] ) ;
42
42
}
43
- async init ( page : Page ) {
43
+ async init ( page : Page ) {
44
44
await checkElementExists ( page , "pierce/#run" ) ;
45
45
for ( let i = 0 ; i < this . benchmarkInfo . warmupCount ; i ++ ) {
46
+ await puppeteerWait ( ) ;
46
47
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 ( ) ;
48
54
await clickElement ( page , "pierce/#clear" ) ;
49
55
await checkElementNotExists ( page , "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)" ) ;
50
56
}
51
57
}
52
58
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
+ ) ;
55
65
}
56
66
} ) ( ) ;
57
67
@@ -60,15 +70,23 @@ export const benchReplaceAll = new (class extends CPUBenchmarkPuppeteer {
60
70
super ( cpuBenchmarkInfos [ Benchmark . _02 ] ) ;
61
71
}
62
72
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
+ }
68
82
}
69
83
async run ( page : Page ) {
70
84
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
+ ) ;
72
90
}
73
91
} ) ( ) ;
74
92
@@ -80,14 +98,22 @@ export const benchUpdate = new (class extends CPUBenchmarkPuppeteer {
80
98
await checkElementExists ( page , "pierce/#run" ) ;
81
99
await clickElement ( page , "pierce/#run" ) ;
82
100
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
+ }
87
109
}
88
110
async run ( page : Page ) {
89
111
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
+ ) ;
91
117
}
92
118
} ) ( ) ;
93
119
@@ -106,8 +132,8 @@ export const benchSelect = new (class extends CPUBenchmarkPuppeteer {
106
132
}
107
133
}
108
134
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" ) ;
111
137
}
112
138
} ) ( ) ;
113
139
@@ -116,21 +142,21 @@ export const benchSwapRows = new (class extends CPUBenchmarkPuppeteer {
116
142
super ( cpuBenchmarkInfos [ Benchmark . _05 ] ) ;
117
143
}
118
144
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
+ }
127
153
}
128
154
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 ) ;
134
160
}
135
161
} ) ( ) ;
136
162
@@ -143,44 +169,79 @@ export const benchRemove = new (class extends CPUBenchmarkPuppeteer {
143
169
await checkElementExists ( page , "pierce/#run" ) ;
144
170
await clickElement ( page , "pierce/#run" ) ;
145
171
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
+ ) ;
154
196
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
+ ) ;
159
212
}
160
213
async run ( page : Page ) {
161
214
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
+ ) ;
163
220
}
164
221
} ) ( ) ;
165
222
export const benchRunBig = new ( class extends CPUBenchmarkPuppeteer {
166
223
constructor ( ) {
167
- super ( cpuBenchmarkInfos [ Benchmark . _07 ] ) ;
224
+ super ( cpuBenchmarkInfos [ Benchmark . _07 ] ) ;
168
225
}
169
226
async init ( page : Page ) {
170
227
await checkElementExists ( page , "pierce/#run" ) ;
171
228
for ( let i = 0 ; i < this . benchmarkInfo . warmupCount ; i ++ ) {
172
229
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
+ ) ;
174
235
await clickElement ( page , "pierce/#clear" ) ;
175
236
await checkElementNotExists ( page , "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)" ) ;
176
- }
237
+ }
177
238
}
178
239
async run ( page : Page ) {
179
240
await clickElement ( page , "pierce/#runlots" ) ;
180
241
await checkElementExists ( page , "pierce/tbody>tr:nth-of-type(10000)>td:nth-of-type(2)>a" ) ;
181
242
}
182
243
} ) ( ) ;
183
-
244
+
184
245
export const benchAppendToManyRows = new ( class extends CPUBenchmarkPuppeteer {
185
246
constructor ( ) {
186
247
super ( cpuBenchmarkInfos [ Benchmark . _08 ] ) ;
@@ -189,10 +250,14 @@ export const benchAppendToManyRows = new (class extends CPUBenchmarkPuppeteer {
189
250
await checkElementExists ( page , "pierce/#run" ) ;
190
251
for ( let i = 0 ; i < this . benchmarkInfo . warmupCount ; i ++ ) {
191
252
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
+ ) ;
193
258
await clickElement ( page , "pierce/#clear" ) ;
194
259
await checkElementNotExists ( page , "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)" ) ;
195
- }
260
+ }
196
261
await clickElement ( page , "pierce/#run" ) ;
197
262
await checkElementExists ( page , "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)" ) ;
198
263
}
@@ -210,16 +275,24 @@ export const benchClear = new (class extends CPUBenchmarkPuppeteer {
210
275
await checkElementExists ( page , "pierce/#run" ) ;
211
276
for ( let i = 0 ; i < this . benchmarkInfo . warmupCount ; i ++ ) {
212
277
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
+ ) ;
214
283
await clickElement ( page , "pierce/#clear" ) ;
215
284
await checkElementNotExists ( page , "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)" ) ;
216
285
}
217
286
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
+ ) ;
219
292
}
220
293
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)" ) ;
223
296
}
224
297
} ) ( ) ;
225
298
@@ -303,27 +376,31 @@ export const benchCreateClear5Memory = new (class extends MemBenchmarkPuppeteer
303
376
async run ( page : Page ) {
304
377
for ( let i = 0 ; i < 5 ; i ++ ) {
305
378
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
+ ) ;
307
384
await clickElement ( page , "pierce/#clear" ) ;
308
385
await checkElementNotExists ( page , "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)" ) ;
309
386
}
310
387
}
311
388
} ) ( ) ;
312
389
313
390
export const benchmarks = [
314
- benchRun ,
391
+ benchRun ,
315
392
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 ,
325
402
benchUpdate5Memory ,
326
- // benchReplace5Memory,
403
+ // benchReplace5Memory,
327
404
benchCreateClear5Memory ,
328
405
benchRun10KMemory ,
329
406
] ;
0 commit comments