def speedtest ( func , * args , * * kwargs ) : n = 100 start = time . time ( ) for i in range ( n ) : func ( * args , * * kwargs ) end = time . time ( ) return ( end - start ) / n
timing how long a function takes to complete in python
Test the speed of a function .
def speedtest(func, *args, **kwargs):
    """ Test the speed of a function. """
    n = 100
    start = time.time()
    for i in range(n): func(*args,**kwargs)
    end = time.time()
    return (end-start)/n