import time


def throttle(f):
    """
    Adds a delay to the desired function, proportional to
    the time it takes to run.
    """

    def wrap(*args, **kwargs):
        t0 = time.time()
        r = f(*args, **kwargs)
        time.sleep((time.time() - t0) * 2)
        return r

    return wrap