#!/usr/bin/env bash # time07.sh — re-measure cycle 07 P3 ("cost 5-10% from an indirect call on every fn"). # # The thing under test is the cost paid by code EMITTED by the new codegen, so # both binaries must be gen3 (self-emitted by their own commit's compiler): # /tmp/elc07pb = elc self-emitted at bc2f26d^ (b40754f) — wrapper calls the body DIRECTLY # /tmp/elc07b = elc self-emitted at bc2f26d — wrapper calls through el_seam_wrap # Both are given the SAME input (bc2f26d's lang/elc-cli.el, CWD = bc2f26d worktree), # so the only difference is the emitted calling convention inside the binary. # Runs are interleaved to spread any drift in machine load across both arms. set -uo pipefail N="${1:-11}" cd /tmp/rerun-v1-07/lang || exit 1 run_one() { # $1 = binary ; prints elapsed seconds local s e s=$(python3 -c 'import time;print(time.perf_counter())') "$1" elc-cli.el > /dev/null 2>&1 e=$(python3 -c 'import time;print(time.perf_counter())') python3 -c "print(f'{$e-$s:.4f}')" } # warm the page cache for both run_one /tmp/elc07pb > /dev/null; run_one /tmp/elc07b > /dev/null P=(); C=() for i in $(seq 1 "$N"); do P+=("$(run_one /tmp/elc07pb)") C+=("$(run_one /tmp/elc07b)") done echo "parent bc2f26d^ (direct call) samples: ${P[*]}" echo "commit bc2f26d (el_seam_wrap) samples: ${C[*]}" echo python3 - "$N" "${P[@]}" "${C[@]}" <<'PY' import sys, statistics n=int(sys.argv[1]); v=[float(x) for x in sys.argv[2:]] p,c=v[:n],v[n:] def stats(x): return min(x), statistics.median(x), max(x) pm,pmd,pmx=stats(p); cm,cmd,cmx=stats(c) print(f"parent n={n} min={pm:.4f}s median={pmd:.4f}s max={pmx:.4f}s") print(f"commit n={n} min={cm:.4f}s median={cmd:.4f}s max={cmx:.4f}s") print() print(f"ratio on min : {cm/pm:.4f} ({(cm/pm-1)*100:+.2f}%)") print(f"ratio on median : {cmd/pmd:.4f} ({(cmd/pmd-1)*100:+.2f}%)") PY echo echo "== machine ==" uname -a sysctl -n machdep.cpu.brand_string 2>/dev/null uptime