import functools
import time


def timer(func):
    """
    Wrapper that reports how long it took to execute a function.
    """

    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        print("--- start ---")
        start_time = time.time()
        output = func(*args, **kwargs)
        elapsed_time = time.time() - start_time
        min_, sec = divmod(round(elapsed_time), 60)
        hour, min_ = divmod(min_, 60)
        print(f"{func.__name__} takes {hour}h: {min_}min: {sec}sec to run")
        print("--- end ---")
        return output

    return wrapper