import functools
import time


def timeit(func):
    """
    This function is used to time function executions.

    Usage:

    @timeit
    def func():
        pass

    """
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        start = time.time()
        result = func(*args, **kwargs)
        end = time.time()
        print("Function {0} took {1} secs to run.".format(
            func.__name__, end - start))
        return result
    return wrapper