omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / om / sha256 / om2-evidence / s4 / measure / run.py
| 1 | import json, os, random, subprocess, sys |
| 2 | ROUNDS=31; WARM=3; REPS=31; SEED=20261025 |
| 3 | random.seed(SEED) |
| 4 | arms={"A":"/tmp/zl/bench/bench-A","B":"/tmp/zl/bench/bench-B"} |
| 5 | def run(p): |
| 6 | out=subprocess.run(["taskset","-c","3","nice","-n","19",p,str(REPS)],capture_output=True,text=True) |
| 7 | if out.returncode!=0: sys.exit("arm failed: "+p+" "+out.stderr[:300]) |
| 8 | rows={} |
| 9 | for line in out.stdout.strip().splitlines(): |
| 10 | f=line.split() |
| 11 | if f[0]=="stream": |
| 12 | rows[f"stream:{f[1]}"]={"min":float(f[3]),"med":float(f[4]),"p90":float(f[5]),"max":float(f[6]),"MBps":float(f[7]),"dig":f[8]} |
| 13 | else: |
| 14 | rows["hash:"+f[1]]={"min":float(f[2]),"med":float(f[3]),"p90":float(f[4]),"max":float(f[5]),"nspb":float(f[6]),"dig":f[7]} |
| 15 | return rows |
| 16 | data={a:{} for a in arms} |
| 17 | for r in range(WARM+ROUNDS): |
| 18 | order=list(arms); random.shuffle(order) |
| 19 | for a in order: |
| 20 | rows=run(arms[a]) |
| 21 | if r>=WARM: |
| 22 | for k,v in rows.items(): data[a].setdefault(k,[]).append(v) |
| 23 | json.dump(data,open("/tmp/zl/bench/raw.json","w"),indent=0) |
| 24 | def med(xs): xs=sorted(xs); n=len(xs); return xs[n//2] if n%2 else (xs[n//2-1]+xs[n//2])/2 |
| 25 | print(f"{'case':22s} {'A med ns':>10s} {'A min..max':>22s} {'B med ns':>10s} {'B min..max':>22s} {'ratio B/A':>9s} {'rmin..rmax':>14s}") |
| 26 | for k in data["A"]: |
| 27 | A=data["A"][k]; B=data["B"][k] |
| 28 | am=med([x["med"] for x in A]); bm=med([x["med"] for x in B]) |
| 29 | ratios=sorted(b["med"]/a["med"] for a,b in zip(A,B)) |
| 30 | units="MB/s" if k.startswith("stream") else "ns" |
| 31 | print(f"{k:22s} {am:10.1f} {min(x['min'] for x in A):9.1f}..{max(x['max'] for x in A):<11.1f} {bm:10.1f} {min(x['min'] for x in B):9.1f}..{max(x['max'] for x in B):<11.1f} {med(ratios):9.3f} {ratios[0]:6.3f}..{ratios[-1]:<6.3f} {units}") |