import os,subprocess,resource,sys,time from pathlib import Path p=Path(__file__).parent.resolve();os.chdir(p) def cap(): resource.setrlimit(resource.RLIMIT_AS,(2*1024**3,2*1024**3));resource.setrlimit(resource.RLIMIT_CPU,(300,300));os.sched_setaffinity(0,{min(os.sched_getaffinity(0))}) for name in ['gap_order','fixture']:subprocess.run(['g++','-O3','-std=c++17',name+'.cpp','-o',name],check=True) t=time.monotonic() for name,out in [('gap_order','permutations.txt'),('fixture','fixture.txt')]: with open(out,'w') as f:subprocess.run(['./'+name],check=True,stdout=f,preexec_fn=cap) subprocess.run([sys.executable,'analyze.py'],check=True,preexec_fn=cap) print(f'elapsed_seconds={time.monotonic()-t:.3f}',file=sys.stderr)