| 208 | // ABBA order so drift within a launch affects both arms alike. `onTrial` reports the |
| 209 | // page being measured, for failure screenshots. |
| 210 | async function measureTrials(pages, scenario, arms, block, options, samples, onTrial) { |
| 211 | for (let trial = -options.warmup; trial < options.samples; trial++) { |
| 212 | let order = (trial + options.warmup) % 2 ? [...arms].reverse() : arms; |
| 213 | for (let [position, arm] of order.entries()) { |
| 214 | let current = pages[arm]; |
| 215 | onTrial(current); |
| 216 | // Keep the measured page frontmost so headed windows are never occluded. |
| 217 | await current.page.bringToFront(); |
| 218 | await prepare(current.page, scenario, current.size); |
| 219 | let sample = await perform(current, scenario); |
| 220 | if (current.errors.length) { |
| 221 | throw new Error(current.errors.join('\n')); |
| 222 | } |
| 223 | if (trial >= 0) { |
| 224 | samples.push({ |
| 225 | scenario: scenario.id, |
| 226 | arm, |
| 227 | block, |
| 228 | trial, |
| 229 | position, |
| 230 | ...sample, |
| 231 | metrics: metrics(sample) |
| 232 | }); |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | async function diagnose(browser, server, result, dir, isInterrupted) { |
| 239 | for (let scenario of result.scenarios) { |