(func, setup="pass", limit=None)
return (number, time, time*_scales[order], _units[order])
Adaptively measure execution time of a function.
Adaptively measure execution time of a function.
Adaptively measure execution time of a function .
def timed(func, setup="pass", limit=None):
    """Adaptively measure execution time of a function. """
    timer = timeit.Timer(func, setup=setup)
    repeat, number = 3, 1

    for i in range(1, 10):
        if timer.timeit(number) >= 0.2:
            break
        elif limit is not None and number >= limit:
            break
        else:
            number *= 10

    time = min(timer.repeat(repeat, number)) / number

    if time > 0.0:
        order = min(-int(math.floor(math.log10(time)) // 3), 3)
    else:
        order = 3

    return (number, time, time*_scales[order], _units[order])
def timed ( func , setup = "pass" , limit = None ) : timer = timeit . Timer ( func , setup = setup ) repeat , number = 3 , 1 for i in range ( 1 , 10 ) : if timer . timeit ( number ) >= 0.2 : break elif limit is not None and number >= limit : break else : number *= 10 time = min ( timer . repeat ( repeat , number ) ) / number if time > 0.0 : order = min ( - int ( math . floor ( math . log10 ( time ) ) // 3 ) , 3 ) else : order = 3 return ( number , time , time * _scales [ order ] , _units [ order ] )