Ejemplo n.º 1
0
def schedule_for(current_track, task, client_index):
    """
    Calculates a client's schedule for a given task.

    :param current_track: The current track.
    :param task: The task that should be executed.
    :param client_index: The current client index.  Must be in the range [0, `task.clients').
    :return: A generator for the operations the given client needs to perform for this task.
    """
    op = task.operation
    num_clients = task.clients
    target_throughput = task.target_throughput / num_clients if task.target_throughput else None
    runner_for_op = runner.runner_for(op.type)
    params_for_op = track.operation_parameters(current_track, op).partition(
        client_index, num_clients)

    if task.warmup_time_period is not None:
        logger.info(
            "Creating time period based schedule for [%s] with a warmup period of [%d] seconds."
            % (op, task.warmup_time_period))
        return time_period_based(target_throughput, task.warmup_time_period,
                                 runner_for_op, params_for_op)
    else:
        logger.info(
            "Creating iteration-count based schedule for [%s] with [%d] warmup iterations and [%d] iterations."
            % (op, task.warmup_iterations, task.iterations))
        return iteration_count_based(target_throughput,
                                     task.warmup_iterations // num_clients,
                                     task.iterations // num_clients,
                                     runner_for_op, params_for_op)
Ejemplo n.º 2
0
def schedule_for(current_track, task, client_index):
    """
    Calculates a client's schedule for a given task.

    :param current_track: The current track.
    :param task: The task that should be executed.
    :param client_index: The current client index.  Must be in the range [0, `task.clients').
    :return: A generator for the operations the given client needs to perform for this task.
    """
    op = task.operation
    num_clients = task.clients
    target_throughput = task.target_throughput / num_clients if task.target_throughput else None
    runner_for_op = runner.runner_for(op.type)
    params_for_op = track.operation_parameters(current_track, op).partition(client_index, num_clients)

    if task.warmup_time_period is not None or task.time_period is not None:
        warmup_time_period = task.warmup_time_period if task.warmup_time_period else 0
        logger.info("Creating time-period based schedule for [%s] with a warmup period of [%s] seconds and a time period of [%s] seconds."
                    % (op, str(warmup_time_period), str(task.time_period)))
        return time_period_based(target_throughput, warmup_time_period, task.time_period, runner_for_op, params_for_op)
    else:
        logger.info("Creating iteration-count based schedule for [%s] with [%d] warmup iterations and [%d] iterations." %
                    (op, task.warmup_iterations, task.iterations))
        return iteration_count_based(target_throughput, task.warmup_iterations // num_clients, task.iterations // num_clients,
                                     runner_for_op, params_for_op)