U e5d4@sddlZddlZddlZddlZddddgZdZdZdZejZ e Z d Z d d Z Gd ddZd d e edfddZd d e eedfddZdddddZedkreedS)NTimertimeitrepeat default_timerz i@Bz def inner(_it, _timer{init}): {setup} _t0 = _timer() for _i in _it: {stmt} _t1 = _timer() return _t1 - _t0 cCs|ddd|S)N  )replace)srcindentr /usr/lib64/python3.8/timeit.pyreindentOsrc@sLeZdZddedfddZd ddZefddZeefd d Z dd d Z dS)rpassNc Cs||_i}|dkrtn|}d}t|trJt|td|d}t|d}n*t|rl||d<|d7}d}d}ntdt|trt||tdt|d }n&t|r||d <|d 7}d }ntd t j |||d} | |_ t| td} t | |||d|_ dS)Nexecr_setupz, _setup=_setupz_setup()z&setup is neither a string nor callableZ_stmtz , _stmt=_stmtz_stmt()z%stmt is neither a string nor callable)stmtsetupinitinner)timer_globals isinstancestrcompiledummy_src_namercallable ValueErrortemplateformatr rr) selfrrrglobalsZlocal_nsZ global_nsrZ stmtprefixr coder r r __init__es6       zTimer.__init__cCsJddl}ddl}|jdk r:t|jd|jdtf|jt<|j|ddS)Nrrfile) linecache tracebackr lensplitrcache print_exc)r#r(r)r*r r r r.s   zTimer.print_exccCsBtd|}t}tz|||j}W5|rgư>gMbP?g?)ZnsecZusecZmsecZsec)z-nz--number)z-sz--setup)z-uz--unitz:Unrecognized unit. Please select nsec, usec, msec, or sec.r')z-rz--repeat)z-pz --process)z-vz --verbose)z-hz--helpr)endcs.d}|dk}t|j||rdnd|ddS)Nz%{num} loop{s} -> {secs:.{prec}g} secsr9sr)ZnumrKZsecsZprec)printr")r2r>msgZplural) precisionr r r<?s zmain..callbackcs`}|dk r|}n8ddD}|jdd|D]\}}||kr8qNq8d|||fS)NcSsg|]\}}||fqSr r ).0unitscaler r r Ysz-main..format_time..T)reversez%.*g %s)itemssort)dtrPrQZscales)rN time_unitunitsr r format_timeSs   zmain..format_timez raw times: %sz, csg|] }|qSr r )rOrV)r2r r rRdszmain..z"%d loop%s, best of %d: %s per looprKrrztThe test results are likely unreliable. The worst time (%s) was more than four times slower than the best time (%s).)sysargvgetopterrorrLrjoinrDintr5stderrrF process_time__doc__ospathinsertcurdirrr?r.rmapminmaxwarnings warn_explicit UserWarning)argsrEr\ZoptserrrrrrrGoarcr8r<_Z raw_timingsrYZtimingsZbestZworstrjr )r2rNrWrXr mains              rr__main__)N)r1rZrFr0__all__rrCrD perf_counterrr$rr!rrrrrrr@exitr r r r 4s4