import time


def timeit(f):
    """
    time a function by applying a decorator

    Parameters
    ----------
    f: function 

    Returns
    -------
    a decorated function 

    """
    def new_f(*args, **kwargs):
        bt = time.time()
        r = f(*args, **kwargs)
        et = time.time()
        print("time spent on {0}: {1:.2f}s".format(f.__name__, et - bt))
        return r
    return new_f