@@ -242,6 +242,196 @@ def runtime_chart(runs, components):
242242 return f'<svg viewBox="0 0 900 { y + 20 } " role="img" aria-label="Component runtime mean and standard deviation"><text x="310" y="18">0 seconds</text><text x="790" y="18">{ maximum :.1f} s</text>{ "" .join (rows )} </svg>'
243243
244244
245+ def outcome_keys (runs ):
246+ """Preserve first-appearance order across runs, mirroring component ordering."""
247+ keys = []
248+ for run in runs :
249+ for component , cdata in run ["component_summaries" ].get ("components" , {}).items ():
250+ for table , tdata in cdata .get ("tables" , {}).items ():
251+ for outcome in tdata .get ("outcomes" , {}):
252+ key = (component , table , outcome )
253+ if key not in keys :
254+ keys .append (key )
255+ return keys
256+
257+
258+ def outcome_data (run , key ):
259+ component , table , outcome = key
260+ tables = (
261+ run ["component_summaries" ].get ("components" , {}).get (component , {}).get ("tables" , {})
262+ )
263+ return tables .get (table , {}).get ("outcomes" , {}).get (outcome )
264+
265+
266+ def outcome_categories (runs , key ):
267+ """Union category labels across runs; nulls sort last for readability."""
268+ categories = []
269+ for run in runs :
270+ for category in (outcome_data (run , key ) or {}).get ("counts" , {}):
271+ if category not in categories :
272+ categories .append (category )
273+ return sorted (categories , key = lambda c : (c == "<null>" , c ))
274+
275+
276+ def outcome_totals (runs , key ):
277+ return [sum ((outcome_data (run , key ) or {}).get ("counts" , {}).values ()) for run in runs ]
278+
279+
280+ def outcome_table (runs , key , categories ):
281+ headers = "" .join (f"<th>{ escape (run ['spec' ]['label' ])} </th>" for run in runs )
282+ totals = outcome_totals (runs , key )
283+ rows = []
284+ for category in categories :
285+ cells = []
286+ for run , total in zip (runs , totals ):
287+ count = (outcome_data (run , key ) or {}).get ("counts" , {}).get (category )
288+ if count is None :
289+ cells .append ("<td>—</td>" )
290+ else :
291+ share = f"{ count / total * 100 :.1f} %" if total else "—"
292+ cells .append (f"<td>{ count :,} <br><small>{ share } </small></td>" )
293+ rows .append (f"<tr><th>{ escape (category )} </th>{ '' .join (cells )} </tr>" )
294+ omitted = [
295+ run ["spec" ]["label" ]
296+ for run in runs
297+ if "counts_omitted" in (outcome_data (run , key ) or {})
298+ ]
299+ note = (
300+ f"<p><small>Exact category counts omitted (category limit exceeded) for: "
301+ f"{ escape (', ' .join (omitted ))} .</small></p>"
302+ if omitted
303+ else ""
304+ )
305+ return f"<table><tr><th>Value</th>{ headers } </tr>{ '' .join (rows )} </table>{ note } "
306+
307+
308+ def outcome_chart (runs , key , categories ):
309+ """Grouped horizontal bars compare each category's share of non-null observations."""
310+ totals = outcome_totals (runs , key )
311+ rows = []
312+ y = 30
313+ for category in categories :
314+ rows .append (f'<text x="5" y="{ y + 12 } ">{ escape (category )} </text>' )
315+ for i , (run , total ) in enumerate (zip (runs , totals )):
316+ count = (outcome_data (run , key ) or {}).get ("counts" , {}).get (category )
317+ if count and total :
318+ share = count / total * 100
319+ width = share * 5.3
320+ rows .append (
321+ f'<rect x="310" y="{ y } " width="{ width :.2f} " height="12" fill="{ COLORS [i % len (COLORS )]} ">'
322+ f'<title>{ escape (run ["spec" ]["label" ])} : { count :,} ({ share :.1f} %)</title></rect>'
323+ )
324+ y += 17
325+ y += 10
326+ return (
327+ f'<svg viewBox="0 0 900 { y + 20 } " role="img" aria-label="Outcome category share">'
328+ f'<text x="310" y="18">0%</text><text x="790" y="18">100%</text>{ "" .join (rows )} </svg>'
329+ )
330+
331+
332+ def numeric_table (runs , key ):
333+ headers = "" .join (f"<th>{ escape (run ['spec' ]['label' ])} </th>" for run in runs )
334+ rows = []
335+ for label , stat in (("Mean" , "mean" ), ("Minimum" , "min" ), ("Maximum" , "max" )):
336+ cells = []
337+ for run in runs :
338+ numeric = (outcome_data (run , key ) or {}).get ("numeric" )
339+ cells .append (f"<td>{ numeric [stat ]:.3f} </td>" if numeric else "<td>—</td>" )
340+ rows .append (f"<tr><th>{ label } </th>{ '' .join (cells )} </tr>" )
341+ return f"<table><tr><th>Statistic</th>{ headers } </tr>{ '' .join (rows )} </table>"
342+
343+
344+ def numeric_chart (runs , key ):
345+ """Grouped bars compare the mean with a min/max whisker on a shared scale."""
346+ values = [(outcome_data (run , key ) or {}).get ("numeric" ) for run in runs ]
347+ present = [v for v in values if v ]
348+ minimum = min ((v ["min" ] for v in present ), default = 0 )
349+ maximum = max ((v ["max" ] for v in present ), default = 1 )
350+ span = (maximum - minimum ) or 1
351+ rows = []
352+ y = 30
353+ for i , (run , value ) in enumerate (zip (runs , values )):
354+ if value :
355+ scale = 530 / span
356+ mean_x = 310 + (value ["mean" ] - minimum ) * scale
357+ lo_x = 310 + (value ["min" ] - minimum ) * scale
358+ hi_x = 310 + (value ["max" ] - minimum ) * scale
359+ rows .append (
360+ f'<rect x="{ mean_x - 2 :.2f} " y="{ y } " width="4" height="12" fill="{ COLORS [i % len (COLORS )]} ">'
361+ f'<title>{ escape (run ["spec" ]["label" ])} : mean { value ["mean" ]:.3f} , '
362+ f'range [{ value ["min" ]:.3f} , { value ["max" ]:.3f} ]</title></rect>'
363+ f'<path d="M { lo_x :.2f} { y + 6 } H { hi_x :.2f} " stroke="#222"/>'
364+ )
365+ y += 17
366+ return (
367+ f'<svg viewBox="0 0 900 { y + 20 } " role="img" aria-label="Outcome numeric range">'
368+ f'<text x="310" y="18">{ minimum :.2f} </text><text x="790" y="18">{ maximum :.2f} </text>'
369+ f'{ "" .join (rows )} </svg>'
370+ )
371+
372+
373+ def summary_table (runs , key ):
374+ """High-cardinality, non-numeric outcomes (e.g. free-form ids) get counts only."""
375+ headers = "" .join (f"<th>{ escape (run ['spec' ]['label' ])} </th>" for run in runs )
376+ rows = []
377+ for label , stat in (
378+ ("Non-null count" , "count" ),
379+ ("Nulls" , "nulls" ),
380+ ("Distinct values" , "distinct" ),
381+ ):
382+ cells = []
383+ for run in runs :
384+ data = outcome_data (run , key )
385+ cells .append (f"<td>{ data [stat ]:,} </td>" if data and stat in data else "<td>—</td>" )
386+ rows .append (f"<tr><th>{ label } </th>{ '' .join (cells )} </tr>" )
387+ return f"<table><tr><th>Statistic</th>{ headers } </tr>{ '' .join (rows )} </table>"
388+
389+
390+ def outcomes_section (runs ):
391+ """Compare per-model outcome distributions across runs, switching table/plot."""
392+ keys = outcome_keys (runs )
393+ if not keys :
394+ return ""
395+ options = []
396+ panels = []
397+ for index , key in enumerate (keys ):
398+ component , table , outcome = key
399+ anchor = f"outcome-{ index } "
400+ options .append (
401+ f'<option value="{ anchor } ">{ escape (f"{ component } · { table } · { outcome } " )} </option>'
402+ )
403+ categories = outcome_categories (runs , key )
404+ if categories :
405+ body = (
406+ f'<div class="table-view">{ outcome_table (runs , key , categories )} </div>'
407+ f'<div class="plot-view">{ outcome_chart (runs , key , categories )} </div>'
408+ )
409+ elif any ((outcome_data (run , key ) or {}).get ("numeric" ) for run in runs ):
410+ body = (
411+ f'<div class="table-view">{ numeric_table (runs , key )} </div>'
412+ f'<div class="plot-view">{ numeric_chart (runs , key )} </div>'
413+ )
414+ else :
415+ body = summary_table (runs , key )
416+ style = "" if index == 0 else "display:none"
417+ panels .append (f'<div class="outcome-panel" id="{ anchor } " style="{ style } ">{ body } </div>' )
418+ return (
419+ "<h2>Component outcomes</h2>"
420+ "<p>Model choice distributions recovered from ActivitySim checkpoints, merged across "
421+ "worker partitions. Shares are of non-null observations within each run; household "
422+ "samples can differ across experiments, so compare shares rather than raw counts. "
423+ "Outcomes too high-cardinality for exact category counts show mean with a min/max "
424+ "range instead.</p>"
425+ '<label for="outcome-select"><b>Outcome:</b></label> '
426+ f'<select id="outcome-select">{ "" .join (options )} </select> '
427+ '<span class="outcome-toggle">'
428+ '<button type="button" data-view="table" class="active">Table</button>'
429+ '<button type="button" data-view="plot">Plot</button>'
430+ "</span>"
431+ f'<div id="outcomes-section" class="scroll">{ "" .join (panels )} </div>'
432+ )
433+
434+
245435def experiment_card (run , xmax , ymax ):
246436 """Present the primary settings and counts before detailed provenance."""
247437 spec = run ["spec" ]
@@ -426,15 +616,38 @@ def report(directories, destination):
426616highlightComponent();
427617</script>
428618"""
619+ outcomes_html = outcomes_section (runs )
620+ # Outcome labels live only in escaped HTML attributes/text, never in JS.
621+ outcomes_script = """
622+ <script>
623+ const outcomeSelect = document.getElementById('outcome-select');
624+ const outcomesSection = document.getElementById('outcomes-section');
625+ if (outcomeSelect) {
626+ outcomeSelect.addEventListener('change', () => {
627+ document.querySelectorAll('.outcome-panel').forEach(panel => {
628+ panel.style.display = panel.id === outcomeSelect.value ? '' : 'none';
629+ });
630+ });
631+ document.querySelectorAll('.outcome-toggle button').forEach(button => {
632+ button.addEventListener('click', () => {
633+ outcomesSection.classList.toggle('plot-mode', button.dataset.view === 'plot');
634+ document.querySelectorAll('.outcome-toggle button').forEach(b => {
635+ b.classList.toggle('active', b === button);
636+ });
637+ });
638+ });
639+ }
640+ </script>
641+ """ if outcomes_html else ""
429642 document = f"""<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>abench report</title>
430- <style>body{{font:15px system-ui;margin:2rem;color:#17212b}}.cards{{display:flex;gap:24px;overflow-x:auto}}article{{flex:1;min-width:420px;border:1px solid #ccc;padding:16px}}pre{{white-space:pre-wrap;overflow-wrap:anywhere;font-size:12px}}svg{{width:100%;min-width:420px}}table{{border-collapse:collapse;width:100%}}th,td{{padding:10px;text-align:left;border-bottom:1px solid #ddd}}.fastest{{background:#d7f3dc}}small{{color:#58616a}}.runtime{{max-width:1200px}}.scroll{{overflow-x:auto}}</style>
643+ <style>body{{font:15px system-ui;margin:2rem;color:#17212b}}.cards{{display:flex;gap:24px;overflow-x:auto}}article{{flex:1;min-width:420px;border:1px solid #ccc;padding:16px}}pre{{white-space:pre-wrap;overflow-wrap:anywhere;font-size:12px}}svg{{width:100%;min-width:420px}}table{{border-collapse:collapse;width:100%}}th,td{{padding:10px;text-align:left;border-bottom:1px solid #ddd}}.fastest{{background:#d7f3dc}}small{{color:#58616a}}.runtime{{max-width:1200px}}.scroll{{overflow-x:auto}}.outcome-toggle button{{margin-left:4px;border:1px solid #ccc;background:#f4f6f8;padding:4px 10px;border-radius:4px;cursor:pointer}}.outcome-toggle button.active{{background:#0072b2;color:#fff;border-color:#0072b2}}.plot-view{{display:none}}#outcomes-section.plot-mode .table-view{{display:none}}#outcomes-section.plot-mode .plot-view{{display:block}} </style>
431644<h1>abench report</h1><p>Whole-container cgroup v2 memory counts shared pages once, including file cache, kernel memory and the supervisor. Swap is recorded separately in memory.csv. Cache preparation and post-run summaries are excluded. Peak is the kernel high-water mark sampled during the model lifetime, including container startup. Memory panels use identical axes.</p>
432645{ comparison_notes (runs )}
433646<label for="memory-component"><b>Highlight component:</b></label>
434647<select id="memory-component"><option value="">None</option>{ options } </select>
435648<p>Selection applies to every memory chart. Each translucent band is one worker execution; darker overlaps indicate concurrent workers. Gaps remain unshaded. Hover over a band for its worker and time range.</p>
436649<noscript>Enable JavaScript to select and highlight component windows.</noscript>
437- <div class="cards">{ "" .join (cards )} </div><h2>Component runtimes</h2><p>Mean ± population standard deviation across worker executions, with observation count and maximum. These describe worker imbalance, not uncertainty across repeated experiments. Component timings exclude pipeline checkpoint writes; elapsed time includes startup, I/O and coordination. Parallel component times must not be summed to estimate wall time. Green cells mark the fastest successful experiment's mean; failed runs are excluded from winners.</p><div class="scroll"><table><tr><th>Component</th>{ headers } </tr>{ "" .join (table )} </table></div><h2>Runtime comparison</h2><p>{ legend } </p><div class="runtime">{ runtime_chart (runs , components )} </div>{ selector_script } </html>"""
650+ <div class="cards">{ "" .join (cards )} </div><h2>Component runtimes</h2><p>Mean ± population standard deviation across worker executions, with observation count and maximum. These describe worker imbalance, not uncertainty across repeated experiments. Component timings exclude pipeline checkpoint writes; elapsed time includes startup, I/O and coordination. Parallel component times must not be summed to estimate wall time. Green cells mark the fastest successful experiment's mean; failed runs are excluded from winners.</p><div class="scroll"><table><tr><th>Component</th>{ headers } </tr>{ "" .join (table )} </table></div><h2>Runtime comparison</h2><p>{ legend } </p><div class="runtime">{ runtime_chart (runs , components )} </div>{ outcomes_html } { selector_script } { outcomes_script } </html>"""
438651 destination .parent .mkdir (parents = True , exist_ok = True )
439652 destination .write_text (document )
440653 write_json (destination .with_suffix (".json" ), runs )
0 commit comments