| 244 | |
| 245 | // Per-launch paired changes, for inspecting drift over a run and order effects. |
| 246 | function launchSection(result) { |
| 247 | let blocks = [...new Set(result.samples.map(sample => sample.block))].sort((a, b) => a - b); |
| 248 | if (!result.builds.candidate || !blocks.length) { |
| 249 | return []; |
| 250 | } |
| 251 | let signed = value => { |
| 252 | let digits = Math.abs(value).toFixed(2); |
| 253 | // Values that round to zero get no minus sign. |
| 254 | return `${value < 0 && digits !== '0.00' ? '−' : '+'}${digits}`; |
| 255 | }; |
| 256 | let lines = [ |
| 257 | '', |
| 258 | '## Changes by browser launch', |
| 259 | '', |
| 260 | 'Each cell is one launch’s paired change in milliseconds (candidate median minus base median), marked B or C for the arm that led that launch’s ABBA trials. The last two columns are medians over launches led by each arm; a consistent gap between them suggests an order effect. A trend across launches suggests drift during the run.', |
| 261 | '' |
| 262 | ]; |
| 263 | let starts = blocks.map(block => |
| 264 | Math.min( |
| 265 | ...(result.order ?? []) |
| 266 | .filter(entry => entry.block === block && entry.started !== undefined) |
| 267 | .map(entry => entry.started) |
| 268 | ) |
| 269 | ); |
| 270 | if (starts.every(Number.isFinite)) { |
| 271 | lines.push( |
| 272 | `Launch start times, in minutes into the run: ${starts.map(start => (start / 60000).toFixed(1)).join(', ')}.`, |
| 273 | '' |
| 274 | ); |
| 275 | } |
| 276 | lines.push( |
| 277 | `| Scenario | ${blocks.map(block => `L${block + 1}`).join(' | ')} | Base led | Candidate led |`, |
| 278 | `|---|${blocks.map(() => '---:').join('|')}|---:|---:|` |
| 279 | ); |
| 280 | for (let scenario of result.scenarios) { |
| 281 | let metric = scenario.metric ?? 'opportunity'; |
| 282 | let cells = blocks.map(block => { |
| 283 | let median = arm => |
| 284 | percentile( |
| 285 | result.samples |
| 286 | .filter( |
| 287 | sample => |
| 288 | sample.scenario === scenario.id && sample.block === block && sample.arm === arm |
| 289 | ) |
| 290 | .map(sample => sample.metrics[metric]), |
| 291 | 0.5 |
| 292 | ); |
| 293 | let base = median('base'); |
| 294 | let candidate = median('candidate'); |
| 295 | return { |
| 296 | delta: base === null || candidate === null ? null : candidate - base, |
| 297 | led: result.order?.find(entry => entry.block === block && entry.scenario === scenario.id) |
| 298 | ?.arms[0] |
| 299 | }; |
| 300 | }); |
| 301 | let byLead = arm => { |
| 302 | let deltas = cells.filter(cell => cell.led === arm && cell.delta !== null); |
| 303 | return deltas.length |