import functools
import time


def timeit(func):
    """
    This function can be used as a decorator as @timeit.
    It will print out how long the function took to execute.

    :param func: The decorated function
    :return: The wrapped function
    """

    @functools.wraps(func)
    def new_func(*args, **kwargs):
        start_time = time.time()
        res = func(*args, **kwargs)
        elapsed_time = time.time() - start_time
        print(f"function [{func.__name__}] finished in {float(elapsed_time * 1000)} ms")
        return res

    return new_func