import ezstan
from mynumpy import *
from time import time
import dill

n2eval = 10000
n2samp = 100
n2eval_final = 10000
n2samp_final = 100000

store = []
for i in range(150):
    if i in [9,113]:
        continue
    #try:
    logp = ezstan.ezload(i)

    if logp.zlen < 2:
        continue

    t0 = time()
    zs1 = logp.sampling(iter=n2samp,n_jobs=1)
    t1 = time()
    t_samp = (t1-t0)/n2samp

    t0 = time()
    zs2=[logp(randn(logp.zlen)) for k in range(n2eval)]
    t1 = time()
    t_eval = (t1-t0)/n2eval

    #print(zs1,zs2)
    zs1*2
    zs2*2

    print('i',i,'time (100000 samples (m))',t_samp*n2samp_final/60, 'time (10000 evals (s))', t_eval*n2eval_final, 'ratio', t_samp/t_eval)
    store.append((i,t_samp,t_eval))
    #except Exception as exp:
    #    print('fail')

    with open('model_timings2.pk','wb') as fid:
        dill.dump(store,fid)
    
