"""Time single forward runs (1500 -> 2025) of Aletsch and Pizzo Tambau on one core."""
import os, sys, time, platform
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)) + '/..')
import aletsch_forward as af
from oggm import cfg, workflow
cpu = [l.split(':')[1].strip() for l in open('/proc/cpuinfo') if 'model name' in l][0]
print('node', platform.node(), '|', cpu)
for rid in ['RGI60-11.01450', 'RGI60-11.03845']:
    af.RGI_ID = rid
    gdir = af.setup(os.environ['WORKDIR'] + '/' + rid)
    s = gdir.settings
    mf, pf, tb = s['melt_f'], s['prcp_fac'], s['temp_bias']
    ts = []
    for i in range(5):
        t0 = time.time()
        af.forward(gdir, mf, pf, tb, suffix=f'_b{i}')
        ts.append(time.time() - t0)
    print(f'{rid}: runs {[round(t, 2) for t in ts]} s, median {sorted(ts)[2]:.2f} s')
