diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/benchmark.py | 14 | ||||
-rwxr-xr-x | tools/throughput_benchmark.py | 54 |
2 files changed, 68 insertions, 0 deletions
diff --git a/tools/benchmark.py b/tools/benchmark.py index ec233afda..4422764aa 100755 --- a/tools/benchmark.py +++ b/tools/benchmark.py @@ -13,6 +13,7 @@ import shutil from util import run, run_output, root_path, build_path, executable_suffix import tempfile import http_server +import throughput_benchmark # The list of the tuples of the benchmark name and arguments exec_time_benchmarks = [ @@ -116,6 +117,15 @@ def run_thread_count_benchmark(deno_path): return thread_count_map +def run_throughput(deno_exe): + m = {} + m["100M_tcp"] = throughput_benchmark.tcp(deno_exe, 100) + m["100M_cat"] = throughput_benchmark.cat(deno_exe, 100) + m["10M_tcp"] = throughput_benchmark.tcp(deno_exe, 10) + m["10M_cat"] = throughput_benchmark.cat(deno_exe, 10) + return m + + def run_syscall_count_benchmark(deno_path): syscall_count_map = {} syscall_count_map["hello"] = get_strace_summary( @@ -169,6 +179,10 @@ def main(argv): } 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': + new_data["throughput"] = run_throughput(deno_path) if "linux" in sys.platform: # Thread count test, only on linux new_data["thread_count"] = run_thread_count_benchmark(deno_path) diff --git a/tools/throughput_benchmark.py b/tools/throughput_benchmark.py new file mode 100755 index 000000000..be3278b57 --- /dev/null +++ b/tools/throughput_benchmark.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# Copyright 2018 the Deno authors. All rights reserved. MIT license. +# Performs benchmark and append data to //website/data.json. +# If //website/data.json doesn't exist, this script tries to import it from gh-pages branch. +# To view the results locally run ./tools/http_server.py and visit +# http://localhost:4545/website + +import os +import sys +import util +import time +import subprocess + +MB = 1024 * 1024 +ADDR = "127.0.0.1:4544" + + +def cat(deno_exe, megs): + size = megs * MB + start = time.time() + cmd = deno_exe + " tests/cat.ts /dev/zero | head -c %s " % size + print cmd + subprocess.check_output(cmd, shell=True) + end = time.time() + return end - start + + +def tcp(deno_exe, megs): + size = megs * MB + # Run deno echo server in the background. + echo_server = subprocess.Popen( + [deno_exe, "--allow-net", "tests/echo_server.ts", ADDR]) + + time.sleep(1) # wait for deno to wake up. TODO racy. + try: + start = time.time() + cmd = ("head -c %s /dev/zero " % size) + "| nc " + ADDR.replace( + ":", " ") + print cmd + subprocess.check_output(cmd, shell=True) + end = time.time() + return end - start + finally: + echo_server.kill() + + +if __name__ == '__main__': + deno_exe = sys.argv[1] + megs = int(sys.argv[2]) + if not deno_exe or not megs: + print "Usage ./tools/throughput_benchmark.py out/debug/deno 100" + sys.exit(1) + secs = tcp_throughput_benchmark(sys.argv[1], megs) + print secs, "seconds" |