Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-tool-model/blob/main/deployment/fast/final_benchmark.py # omega-tool-model First-party Omega tool-use model source, serving harnesses, and verification records Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-tool-model / deployment / fast / final_benchmark.py` 51 lines ยท 3008 bytes Raw Blame History 1 import os 2 """External installed-client benchmark. No generated commands are executed.""" 3 from pathlib import Path 4 import json,selectors,subprocess,os,time,statistics,hashlib 5 R=Path(__file__).resolve().parent 6 D=(Path(os.path.expanduser('~')) / '/.local/share/omega-tool-model/round40'.lstrip('/')) 7 cases=json.loads((R.parent/'speed/workloads.json').read_text()) 8 old=json.loads((R.parent/'speed/raw.json').read_text()) 9 expected={x['workload']:x['installed']['stdout'] for x in old} 10 tokens={x['workload']:x['instrumented']['output_tokens'] for x in old} 11 def measure(command,prompt): 12 start=time.perf_counter_ns();p=subprocess.Popen([str(command)],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,bufsize=0) 13 p.stdin.write(prompt.encode());p.stdin.close() 14 sel=selectors.DefaultSelector();sel.register(p.stdout,selectors.EVENT_READ,1);sel.register(p.stderr,selectors.EVENT_READ,2) 15 out=bytearray();err=bytearray();first=None;last=None;chunks=[] 16 while sel.get_map(): 17 if time.perf_counter_ns()-start>60_000_000_000: 18 p.kill();p.wait();raise RuntimeError('Own benchmark child timed out') 19 for key,_ in sel.select(1): 20 b=os.read(key.fd,4096);now=time.perf_counter_ns() 21 if not b:sel.unregister(key.fileobj);continue 22 if key.data==1: 23 out.extend(b) 24 if first is None:first=now 25 last=now;chunks.append(dict(at_ns=now-start,bytes=len(b))) 26 else:err.extend(b) 27 rc=p.wait();end=time.perf_counter_ns();sel.close() 28 assert rc==0 and not err,(rc,err) 29 return dict(first_ns=first-start,last_ns=last-start,total_ns=end-start,stdout=out.decode(),chunks=chunks,returncode=rc) 30 rows=[] 31 for rep in range(5): 32 for case in cases: 33 order=['original','resident'] if rep%2==0 else ['resident','original'] 34 for mode in order: 35 command=D/'omega-tool-model' if mode=='original' else (Path(os.path.expanduser('~')) / '/.local/bin/omega-tool-model'.lstrip('/')) 36 a=measure(command,case['prompt']);assert a['stdout']==expected[case['name']] 37 rows.append(dict(mode=mode,rep=rep,case=case['name'],output_tokens=tokens[case['name']],**a)) 38 (R/'final-benchmark-raw.json').write_text(json.dumps(rows,indent=2)+'\n') 39 summary=[] 40 for mode in ('original','resident'): 41 for case in cases: 42 g=[x for x in rows if x['mode']==mode and x['case']==case['name']] 43 s=dict(mode=mode,case=case['name'],repeats=len(g),output_tokens=tokens[case['name']]) 44 for key in ('first_ns','last_ns','total_ns'): 45 v=[x[key]/1e6 for x in g];s[key.replace('_ns','_ms')]=dict(median=statistics.median(v),minimum=min(v),maximum=max(v)) 46 v=[x['output_tokens']*1e9/x['total_ns'] for x in g];s['all_in_tps']=dict(median=statistics.median(v),minimum=min(v),maximum=max(v)) 47 if mode=='resident': 48 v=[(x['output_tokens']-1)*1e9/(x['last_ns']-x['first_ns']) for x in g];s['decode_tps']=dict(median=statistics.median(v),minimum=min(v),maximum=max(v)) 49 summary.append(s) 50 (R/'final-benchmark.json').write_text(json.dumps(summary,indent=2)+'\n') 51 print('Paired installed-client benchmark passed; all outputs match.',flush=True)