Exemple #1
0
def main(argv):
    if len(argv) == 2:
        build_dir = sys.argv[1]
    elif len(argv) == 1:
        build_dir = build_path()
    else:
        print "Usage: tools/benchmark.py [build_dir]"
        sys.exit(1)

    http_server.spawn()

    deno_path = os.path.join(build_dir, "deno")
    benchmark_file = os.path.join(build_dir, "benchmark.json")

    os.chdir(root_path)
    import_data_from_gh_pages()
    # TODO: Use hyperfine in //third_party
    run([
        "hyperfine", "--ignore-failure", "--export-json", benchmark_file,
        "--warmup", "3"
    ] + [
        deno_path + " " + " ".join(args) for [_, args] in exec_time_benchmarks
    ])
    all_data = read_json(all_data_file)
    benchmark_data = read_json(benchmark_file)
    sha1 = run_output(["git", "rev-parse", "HEAD"]).strip()
    new_data = {
        "created_at": time.strftime("%Y-%m-%dT%H:%M:%SZ"),
        "sha1": sha1,
        "binary_size": {},
        "thread_count": {},
        "syscall_count": {},
        "benchmark": {}
    }
    for [[name, _], data] in zip(exec_time_benchmarks,
                                 benchmark_data["results"]):
        new_data["benchmark"][name] = {
            "mean": data["mean"],
            "stddev": data["stddev"],
            "user": data["user"],
            "system": data["system"],
            "min": data["min"],
            "max": data["max"]
        }

    new_data["binary_size"] = get_binary_sizes(build_dir)
    # Cannot run throughput benchmark on windows because they don't have nc or
    # pipe.
    if os.name != 'nt':
        hyper_hello_path = os.path.join(build_dir, "hyper_hello")
        new_data["throughput"] = run_throughput(deno_path)
        new_data["req_per_sec"] = http_benchmark(deno_path, hyper_hello_path)
    if "linux" in sys.platform:
        # Thread count test, only on linux
        new_data["thread_count"] = run_thread_count_benchmark(deno_path)
        new_data["syscall_count"] = run_syscall_count_benchmark(deno_path)

    all_data.append(new_data)
    write_json(all_data_file, all_data)
    write_json(recent_data_file, all_data[-20:])
Exemple #2
0
def run_http(build_dir, new_data):
    stats = http_benchmark(build_dir)
    new_data["req_per_sec"] = {k: v["req_per_sec"] for k, v in stats.items()}
    new_data["max_latency"] = {k: v["max_latency"] for k, v in stats.items()}
Exemple #3
0
def main(argv):
    if len(argv) == 2:
        build_dir = sys.argv[1]
    elif len(argv) == 1:
        build_dir = build_path()
    else:
        print "Usage: tools/benchmark.py [build_dir]"
        sys.exit(1)

    http_server.spawn()

    deno_path = os.path.join(build_dir, "deno")
    benchmark_file = os.path.join(build_dir, "benchmark.json")

    os.chdir(root_path)
    import_data_from_gh_pages()

    hyperfine = prebuilt.load_hyperfine()

    run([
        hyperfine, "--ignore-failure", "--export-json", benchmark_file,
        "--warmup", "3"
    ] + [
        deno_path + " " + " ".join(args) for [_, args] in exec_time_benchmarks
    ])
    all_data = read_json(all_data_file)
    benchmark_data = read_json(benchmark_file)
    sha1 = run_output(["git", "rev-parse", "HEAD"]).strip()
    new_data = {
        "created_at": time.strftime("%Y-%m-%dT%H:%M:%SZ"),
        "sha1": sha1,
        "binary_size": {},
        "thread_count": {},
        "syscall_count": {},
        "benchmark": {}
    }
    for [[name, _], data] in zip(exec_time_benchmarks,
                                 benchmark_data["results"]):
        new_data["benchmark"][name] = {
            "mean": data["mean"],
            "stddev": data["stddev"],
            "user": data["user"],
            "system": data["system"],
            "min": data["min"],
            "max": data["max"]
        }

    new_data["binary_size"] = get_binary_sizes(build_dir)
    # Cannot run throughput benchmark on windows because they don't have nc or
    # pipe.
    if os.name != 'nt':
        hyper_hello_path = os.path.join(build_dir, "hyper_hello")
        core_http_bench_exe = os.path.join(build_dir, "deno_core_http_bench")
        new_data["throughput"] = run_throughput(deno_path)
        new_data["req_per_sec"] = http_benchmark(deno_path, hyper_hello_path,
                                                 core_http_bench_exe)
    if "linux" in sys.platform:
        # Thread count test, only on linux
        new_data["thread_count"] = run_thread_count_benchmark(deno_path)
        new_data["syscall_count"] = run_syscall_count_benchmark(deno_path)

    all_data.append(new_data)
    write_json(all_data_file, all_data)
    write_json(recent_data_file, all_data[-20:])