from pathlib import Path import subprocess,json,csv,hashlib,time,os r=Path('');out=r/'results/master-rounding-grid';out.mkdir(exist_ok=True) rows=[];wine=str(r/'profiling-tools/wine11/opt/wine-stable/bin/wine');env=dict(os.environ,WINEPREFIX=str(r/'wine11-audio-prefix'),WINESERVER=str(r/'profiling-tools/wine11/opt/wine-stable/bin/wineserver'),WINEDEBUG='-all',WINEDLLOVERRIDES='winemenubuilder.exe=d') for platform,ref in [('linux','coherent-volume-main'),('windows','coherent-volume-main-windows11')]: for case in ['lp2-fixed','hp2-fixed','bp2-fixed','lp2-jumps','hp2-jumps','bp2-jumps']: wave=out/(platform+'-'+case+'.f64');subprocess.run([str(r/ref/'audio'),'48000','127','1',case,str(wave),'volume=0'],check=True,stdout=subprocess.DEVNULL) cmd=[str(r/'master-rounding-grid'),str(wave)] if platform=='linux' else [wine,str(r/'master-rounding-grid.exe'),'Z:'+str(wave).replace('/','\\')] started=time.time_ns();s=subprocess.check_output(cmd,env=env,text=True);(out/(platform+'-'+case+'.csv')).write_text(s);row=next(csv.DictReader(s.splitlines()));row.update(platform=platform,case=case,elapsed_ns=time.time_ns()-started,input_sha256=hashlib.sha256(wave.read_bytes()).hexdigest());rows.append(row);print(row,flush=True);wave.unlink() (out/'results.json').write_text(json.dumps(dict(source_sha256=hashlib.sha256((r/'master-rounding-grid.rs').read_bytes()).hexdigest(),rows=rows),indent=2)+'\n')