"""Two session orders with one full warm-up per fresh interpreter."""
import json,subprocess,sys
from pathlib import Path
from versions26 import study as replay

def worker():
    replay()
    d=replay()
    return dict(python=d['python'],starts=d['starts'],rows=d['rows'])

def study(executables):
    rows=[]
    for order in (executables,executables[::-1]):
        for executable in order:
            cmd=[executable,'-B',str(Path(__file__).resolve()),'--worker']
            rows.append(json.loads(subprocess.check_output(cmd)))
    assert all(r['starts']==rows[0]['starts'] for r in rows)
    return rows
if __name__=='__main__':
    import argparse
    p=argparse.ArgumentParser();p.add_argument('--worker',action='store_true');p.add_argument('--second',default=sys.executable);a=p.parse_args()
    print(json.dumps(worker() if a.worker else study([sys.executable,a.second])))
