#!/usr/bin/env python3 """Render a completed WM benchmark run without running workloads.""" from pathlib import Path import argparse,json parser=argparse.ArgumentParser(description=__doc__) parser.add_argument('--input',type=Path,default=Path('wm-results-v1')) parser.add_argument('--output',type=Path,default=Path('bench/wm/RESULTS.md')) args=parser.parse_args() result=json.loads((args.input/'results.json').read_text());config=result['config'] assert config['suite']=='wm' and len(config['cases'])==12 rows=json.loads((args.input/'samples.json').read_text()) verified=json.loads((args.input/'verification.json').read_text()) scaling=json.loads((args.input/'scaling.json').read_text()) assert len(verified)==60 and len(scaling)==4 and all(g['passed'] for g in scaling.values()) assert len(rows)==12*5*(config['samples']+1) medians=result['medians'];overall=result['summary']['all'] variants=['interpreter-arena','interpreter-gc','native-arena','native-gc','guile-3'] lines=['# Mock window-manager results','', f"{config['samples']} measured fresh processes plus one excluded process per workload/configuration. All {len(rows)} checks passed across twelve workloads and five configurations; all 48 seed oracles are derived independently from the Python state model.",'', 'Prepared time includes fresh WM state and the workload itself. Macro expansion/compilation and fixture loading are inside their respective workloads. Shared helper setup is outside timing. First-call and whole-process medians are separate below. OS filesystem caches are not flushed.','', 'Guile/Vile geometric means, equally weighting all twelve workloads:','', '| Configuration | Guile/Vile | Faster cases |','|---|---:|---:|'] for v in variants[:-1]: s=overall[v];lines.append(f"| {v} | {s['geometric_mean_speedup']:.3f}× | {s['faster_cases']}/12 |") lines+=['','Ratios above 1 favor Vile. These workloads describe a headless WM model, not arbitrary applications. Native fallbacks and losses remain in all summaries.','', '| Workload | Interpreter arena ms | Interpreter GC ms | Native arena ms | Native GC ms | Guile ms | Guile/native GC |', '|---|---:|---:|---:|---:|---:|---:|'] for c in config['cases']: n=c['name'];v=medians[n]['variants'];values=[v[k]['per_call_ns']/1e6 for k in variants] lines.append('| '+n+' | '+' | '.join(f'{x:.3f}' for x in values)+f" | {v['guile-3']['per_call_ns']/v['native-gc']['per_call_ns']:.3f}× |") lines+=['','First-call and whole-process medians in milliseconds. Whole process includes the complete four-invocation batch, setup, five warmup invocations and cleanup.','', '| Workload | Native GC first | Guile first | Native GC process | Guile process |','|---|---:|---:|---:|---:|'] for c in config['cases']: n=c['name'];v=medians[n]['variants'] values=[v[k][field]/1e6 for field in ['first_call_ns','whole_process_ns'] for k in ['native-gc','guile-3']] lines.append('| '+n+' | '+' | '.join(f'{x:.3f}' for x in values)+' |') ratios=[g['total_time_ratio'] for g in scaling.values()] lines+=['',f"Four scaling groups cover callback and focus workloads in both native collector configurations: 100× calls took {min(ratios):.1f}–{max(ratios):.1f}× time. Each group uses three repeats of 4 versus 400 invocations.",'', f"Tools: {config['guile_version'].splitlines()[0]}; {config['cpu']}. Guile uses -O2 and default JIT. Native cache policy: `{config['native_cache']}`. Serial Mac jobs use VJOBS=1, VFLAGS=-no-parallel and MAKEFLAGS=-j1 under the shared lock. Builds, verification, scaling and measurement are separate phases.",'', f'Raw rows, median/IQR/range, environment, exact flags and source/tool/binary hashes: `{args.input.resolve()}`. The original numeric/runtime suite is reported separately; no cases are silently omitted.',''] args.output.parent.mkdir(parents=True,exist_ok=True);args.output.write_text('\n'.join(lines));print(args.output)