"""Measure sequential offline builds from source snapshots and fresh Zig caches.""" import argparse import hashlib import json import os import platform import shutil import struct import subprocess import tempfile import time from pathlib import Path parser = argparse.ArgumentParser() parser.add_argument('output', type=Path) args = parser.parse_args() args.output = args.output.resolve() args.output.mkdir(parents=True, exist_ok=True) repo = Path(__file__).resolve().parents[2] flags = ['-Dbackend=zio', '-Doptimize=ReleaseSafe', '-Dtarget=x86_64-linux-gnu', '-j2'] report = {'host': platform.platform(), 'zig': subprocess.check_output(['zig', 'version'], text=True).strip(), 'flags': flags, 'network': 'sandbox-exec deny network*', 'measurements': []} def digest(path): return hashlib.sha256(path.read_bytes()).hexdigest() def snapshot(source, target): target.mkdir(parents=True) for name in ['src', 'build.zig', 'build.zig.zon']: origin = source / name if origin.is_dir(): shutil.copytree(origin, target / name) else: shutil.copy2(origin, target / name) (target / 'zig-pkg').symlink_to(source / 'zig-pkg', target_is_directory=True) def elf(path): data = path.read_bytes() assert data[:6] == b'\x7fELF\x02\x01' offset = struct.unpack_from('