import os, pathlib, subprocess, sys, time
base,head,out=map(pathlib.Path,sys.argv[1:])
for side,count,cwd,home,port in [('before',1186,base,'base-small-home',14633),('after',1186,head,'head-small-home',14634),('before',11860,base,'base-home',14631),('after',11860,head,'head-home',14632)]:
 name=f'final-{side}-{count}'
 with (out/(name+'.log')).open('w') as log:
  subprocess.run(['node','evidence-final-driver.ts',str(out/home),f'http://127.0.0.1:{port}',str(out/(name+'.json'))],cwd=cwd/'apps/server',env={**os.environ,'MEASURE_COUNT':str(count),'SAMPLES':'250'},stdout=log,stderr=subprocess.STDOUT,check=True)
 print(name+' completed',flush=True)
