#!/usr/bin/env python3 """Count exact fine-segment/sample evaluations in the four L80 views.""" from __future__ import annotations import json import re import subprocess import time from pathlib import Path ROOT = Path(__file__).resolve().parents[4] OUT = ROOT / "Saved/Linux/l116/pairs" DATA = ROOT / "Standalone/data/owner_world.json" BIN = ROOT / "Saved/Linux/l116/bin/VoxelForgeCoreHeadless-l116-clang" CAMERAS = { 0: (8.0, 16.0, -372.2626953125), 1: (25.8369140625, 3.19921875, -737.0), 2: (19.166015625, -14.2001953125, -753.3740234375), 3: (-20.0625, -5.068359375, -900.353515625), } PAIRS = re.compile(r"\bsweep_pairs=(\d+)") def run(strate: int) -> dict: OUT.mkdir(parents=True, exist_ok=True) log = OUT / f"L116-s{strate}.log" camera = ",".join(f"{v:.12f}" for v in CAMERAS[strate]) + ",0,0" command = [ "taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--", "timeout", "1740s", str(BIN), str(DATA), "--world-assembler-prototype", "--stream-benchmark", "--stream-pipeline", "--workers=12", "--clip-radius=3", "--max-clip-level=8", "--max-level=8", f"--camera={camera}", "--profile-passage-composer", "--stream-scheduler-policy=3", ] started = time.monotonic() with log.open("w", encoding="utf-8") as stream: result = subprocess.run(command, cwd=ROOT, stdout=stream, stderr=subprocess.STDOUT, check=False, timeout=1740) values = [int(value) for value in PAIRS.findall( log.read_text(encoding="utf-8", errors="replace"))] if result.returncode or not values: raise SystemExit(f"pair profile missing: {log}; exit={result.returncode}") row = {"strate": strate, "tiles": len(values), "segment_sample_pairs": sum(values), "elapsed_s": round(time.monotonic() - started, 3), "log": str(log.relative_to(ROOT))} print("[L116PairCount] " + json.dumps(row, sort_keys=True), flush=True) return row def main() -> int: if not BIN.is_file() or not DATA.is_file(): raise SystemExit("missing L116 pair-count input") rows = [run(strate) for strate in range(4)] summary = {"strata": rows, "total_segment_sample_pairs": sum(row["segment_sample_pairs"] for row in rows)} (OUT / "summary.json").write_text(json.dumps(summary, indent=2) + "\n", encoding="utf-8") return 0 if __name__ == "__main__": raise SystemExit(main())