import functools
import time


def timeit(func):
    """Decorator to measure the time spent by a function."""

    @functools.wraps(func)
    def timed(*args, **kwargs):
        start = time.time()
        result = func(*args, **kwargs)
        end = time.time()
        return end - start, result

    return timed