Пример #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()
Пример #2
0
def _print_pid_mem(pid):
    mem_total = get_total_memory_for_pid(pid)
    mem_total.print()
Пример #3
0
def _plot_pid_mem(pid):
    mem_total = get_total_memory_for_pid(pid)
    mem_total.plot()