import time


def time_function(function, *args, n=10000, **kwargs):
    """ time how long it takes for a function to evaluate n times """
    initial_time = time.time();
    for _ in range(n):
        function(*args, **kwargs);
    final_time = time.time();
    return final_time - initial_time;