"""Measure native counters and actual published files during a scoped QA run.""" import argparse import json import time from pathlib import Path def read_json(path): for _ in range(20): try: return json.loads(path.read_text(encoding='utf-8')) except (PermissionError,json.JSONDecodeError): time.sleep(.01) raise RuntimeError('Could not read profile state') def measure(local,seconds): first=read_json(local/'bridge_status.json')['native_capture']['performance'] changes={name:0 for name in ('screen_frame.png','hud_frame.png','screen_frame.rgba','hud_frame.rgba')} previous={name:(local/name).stat().st_mtime_ns if (local/name).exists() else 0 for name in changes} start=time.monotonic() while time.monotonic()-start