| 324 | |
| 325 | // Main-thread breakdowns of the diagnostic trace reruns, within the measured window. |
| 326 | function traceSection(diagnostics) { |
| 327 | if (!diagnostics.length) { |
| 328 | return []; |
| 329 | } |
| 330 | let lines = [ |
| 331 | '## Diagnostic traces', |
| 332 | '', |
| 333 | 'Each trace is a separate rerun after the same warmups as the measured trials, excluded from comparisons. Times cover the renderer main thread inside the measured window (input to rendering opportunity), attributing each moment to its innermost trace event. Forced style and layout is the part of style and layout that script triggered synchronously; it is already included in those columns.', |
| 334 | '', |
| 335 | '| Scenario / arm | Window | Main thread busy | Script | Style | Layout | Forced style and layout | Paint | GC | Other | Trace |', |
| 336 | '|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---|' |
| 337 | ]; |
| 338 | for (let diagnostic of diagnostics) { |
| 339 | let {summary} = diagnostic; |
| 340 | let label = `${diagnostic.scenario} / ${diagnostic.arm}`; |
| 341 | if (diagnostic.error) { |
| 342 | lines.push( |
| 343 | `| ${label} | FAILED: ${diagnostic.error.replaceAll('|', '\\|').split('\n')[0]} |||||||||| |` |
| 344 | ); |
| 345 | } else if (!summary) { |
| 346 | lines.push(`| ${label} | no measurement window in trace |||||||||| ${diagnostic.file} |`); |
| 347 | } else { |
| 348 | lines.push( |
| 349 | `| ${label} | ${[ |
| 350 | summary.window, |
| 351 | summary.busy, |
| 352 | summary.script, |
| 353 | summary.style, |
| 354 | summary.layout, |
| 355 | summary.forcedStyleLayout, |
| 356 | summary.paint, |
| 357 | summary.gc, |
| 358 | summary.other |
| 359 | ] |
| 360 | .map(ms) |
| 361 | .join(' | ')} | ${diagnostic.file} |` |
| 362 | ); |
| 363 | } |
| 364 | } |
| 365 | lines.push(''); |
| 366 | return lines; |
| 367 | } |
| 368 | |
| 369 | const ms = value => (value === null ? 'unavailable' : `${value.toFixed(2)} ms`); |
| 370 | |