import time


def timeit(stat_tracker_func, name):
    """
    Pass in a function and the name of the stat
    Will time the function that this is a decorator to and send
    the `name` as well as the value (in seconds) to `stat_tracker_func`

    `stat_tracker_func` can be used to either print out the data or save it
    """
    def _timeit(func):
        def wrapper(*args, **kw):
            start_time = time.time()
            result = func(*args, **kw)
            stop_time = time.time()
            stat_tracker_func(name, stop_time - start_time)

            return result
        return wrapper

    return _timeit