def time_func ( func , name , * args , * * kwargs ) : tic = time . time ( ) out = func ( * args , * * kwargs ) toc = time . time ( ) print ( '%s took %0.2f seconds' % ( name , toc - tic ) ) return out
python how to check the time taken for a function
call a func with args and kwargs print name of func and how long it took .
def time_func(func, name, *args, **kwargs):
    """ call a func with args and kwargs, print name of func and how
    long it took. """
    tic = time.time()
    out = func(*args, **kwargs)
    toc = time.time()
    print('%s took %0.2f seconds' % (name, toc - tic))
    return out