import timeit


def get_trial_duration(
    lambda_2, lambda_1, mu, num_of_servers, threshold, trials, repeat_trial
):
    """
    Use the timeit library to get the duration of a trial for a specified
    amount of repetitions

    Parameters
    ----------
    trials : int
        Number of trials to run timeit on
    repeat_trial : int
        Number of repetitions per trial to run timeit on

    Returns
    -------
    list
        A list of floats that represent the time required for the specified
        number of trials to for each repetition
    """
    parameters = [lambda_2, lambda_1, mu, num_of_servers, threshold]
    timeit_string = "simulate_model("
    for par in range(len(parameters)):
        timeit_string += str(parameters[par]) + ","
    timeit_string += ")"
    duration_object = timeit.Timer(
        timeit_string, "from ambulance_game.simulation.simulation import simulate_model"
    )
    duration_of_trial = duration_object.repeat(repeat=repeat_trial, number=trials)
    return duration_of_trial