Ejemplo n.º 1
0
def _run_sleep_bench(bench_name, n_workers, cmd, sleep_time, process_name, csv_out):
    print("BENCH: {} - {} workers".format(bench_name, n_workers))

    # Launch the process in the background
    cmd_str = [
        cmd,
        str(n_workers),
    ]
    cmd_str = " ".join(cmd_str)

    # Set up environment
    set_benchmark_env()

    # Launch subprocess
    sleep_proc = Process(target=_exec_cmd, args=[cmd_str])
    sleep_proc.start()
    sleep(sleep_time)

    pid = get_pid_for_name(process_name)
    print("Measuring memory of process {}".format(pid))
    mem_total = get_total_memory_for_pid(pid)

    for label, value in zip(mem_total.get_labels(), mem_total.get_data()):
        csv_out.write("{},{},{},{},{}\n".format(
            bench_name,
            label,
            value,
            n_workers,
            Decimal(value) / n_workers,
        ))

    csv_out.flush()

    # Rejoin the background process
    sleep_proc.join()
Ejemplo n.º 2
0
def plot_proc_mem(ctx, proc_name):
    """
    Plot the memory usage for the given process name
    """
    pid = get_pid_for_name(proc_name)
    _plot_pid_mem(pid)
Ejemplo n.º 3
0
def proc_mem(ctx, proc_name):
    """
    Show the memory usage for the given process name
    """
    pid = get_pid_for_name(proc_name)
    _print_pid_mem(pid)
Ejemplo n.º 4
0
def plot_proc_mem(ctx, proc_name):
    pid = get_pid_for_name(proc_name)
    _plot_pid_mem(pid)