| 1 | #!/usr/bin/env python3 |
| 2 | """Render a completed WM benchmark run without running workloads.""" |
| 3 | from pathlib import Path |
| 4 | import argparse,json |
| 5 | |
| 6 | parser=argparse.ArgumentParser(description=__doc__) |
| 7 | parser.add_argument('--input',type=Path,default=Path('wm-results-v1')) |
| 8 | parser.add_argument('--output',type=Path,default=Path('bench/wm/RESULTS.md')) |
| 9 | args=parser.parse_args() |
| 10 | result=json.loads((args.input/'results.json').read_text());config=result['config'] |
| 11 | assert config['suite']=='wm' and len(config['cases'])==12 |
| 12 | rows=json.loads((args.input/'samples.json').read_text()) |
| 13 | verified=json.loads((args.input/'verification.json').read_text()) |
| 14 | scaling=json.loads((args.input/'scaling.json').read_text()) |
| 15 | assert len(verified)==60 and len(scaling)==4 and all(g['passed'] for g in scaling.values()) |
| 16 | assert len(rows)==12*5*(config['samples']+1) |
| 17 | medians=result['medians'];overall=result['summary']['all'] |
| 18 | variants=['interpreter-arena','interpreter-gc','native-arena','native-gc','guile-3'] |
| 19 | lines=['# Mock window-manager results','', |
| 20 | 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.",'', |
| 21 | '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.','', |
| 22 | 'Guile/Vile geometric means, equally weighting all twelve workloads:','', |
| 23 | '| Configuration | Guile/Vile | Faster cases |','|---|---:|---:|'] |
| 24 | for v in variants[:-1]: |
| 25 | s=overall[v];lines.append(f"| {v} | {s['geometric_mean_speedup']:.3f}× | {s['faster_cases']}/12 |") |
| 26 | lines+=['','Ratios above 1 favor Vile. These workloads describe a headless WM model, not arbitrary applications. Native fallbacks and losses remain in all summaries.','', |
| 27 | '| Workload | Interpreter arena ms | Interpreter GC ms | Native arena ms | Native GC ms | Guile ms | Guile/native GC |', |
| 28 | '|---|---:|---:|---:|---:|---:|---:|'] |
| 29 | for c in config['cases']: |
| 30 | n=c['name'];v=medians[n]['variants'];values=[v[k]['per_call_ns']/1e6 for k in variants] |
| 31 | 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}× |") |
| 32 | lines+=['','First-call and whole-process medians in milliseconds. Whole process includes the complete four-invocation batch, setup, five warmup invocations and cleanup.','', |
| 33 | '| Workload | Native GC first | Guile first | Native GC process | Guile process |','|---|---:|---:|---:|---:|'] |
| 34 | for c in config['cases']: |
| 35 | n=c['name'];v=medians[n]['variants'] |
| 36 | values=[v[k][field]/1e6 for field in ['first_call_ns','whole_process_ns'] for k in ['native-gc','guile-3']] |
| 37 | lines.append('| '+n+' | '+' | '.join(f'{x:.3f}' for x in values)+' |') |
| 38 | ratios=[g['total_time_ratio'] for g in scaling.values()] |
| 39 | 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.",'', |
| 40 | 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.",'', |
| 41 | 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.',''] |
| 42 | args.output.parent.mkdir(parents=True,exist_ok=True);args.output.write_text('\n'.join(lines));print(args.output) |
| 43 | |