perff.py

Created by andreanx

Created on August 15, 2023

504 Bytes


try:
  from time import *
except:
  pass

def hastime():
  try:
    monotonic()
    return True
  except:
    return False

def seuil(d):
  d=d**2
  timed,n=hastime(),0
  start,u=0 or timed and monotonic(),2.
  while (u-1)**2>=d:
    u=1+1/((1-u)*(n+1))
    n=n+1
  return [(timed and monotonic() or 1) - start,n,u]

def seuilmoy(d=.008):
  s0 = 2*10**-3
  s = s0
  tt, t, c = 0, 0, 0
  while c<2 or abs((tt + t)/c-tt/(c-1))>=s/c:
    tt += t
    t = seuil(d)[0]
    c += 1
  return (tt+t)/c