diff options
author | Dmitry Sharshakov <sh7dm@outlook.com> | 2019-04-16 20:57:05 +0300 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-04-16 13:57:05 -0400 |
commit | 0c463582206881b6461742633a67f51632db614e (patch) | |
tree | ca51d8f32d586d77cd607c9fd50c242eb8f5ea3d /tools/benchmark.py | |
parent | 97f0fe7437ad4277afbdabf6cac214a40b637cd1 (diff) |
Add max memory benchmark (#2061)
Diffstat (limited to 'tools/benchmark.py')
-rwxr-xr-x | tools/benchmark.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/benchmark.py b/tools/benchmark.py index 2e3ac26e4..43476c50b 100755 --- a/tools/benchmark.py +++ b/tools/benchmark.py @@ -17,6 +17,7 @@ import http_server import throughput_benchmark from http_benchmark import http_benchmark import prebuilt +import subprocess # The list of the tuples of the benchmark name and arguments exec_time_benchmarks = [ @@ -154,6 +155,21 @@ def run_syscall_count_benchmark(deno_path): return syscall_count_map +# Takes the output from "/usr/bin/time -v" as input and extracts the 'maximum +# resident set size' and returns it in bytes. +def find_max_mem_in_bytes(time_v_output): + for line in time_v_output.split('\n'): + if 'maximum resident set size (kbytes)' in line.lower(): + _, value = line.split(': ') + return int(value) * 1024 + + +def run_max_mem_benchmark(deno_path): + cmd = ["/usr/bin/time", "-v", deno_path, "--reload", "tests/002_hello.ts"] + out = subprocess.check_output(cmd, stderr=subprocess.STDOUT) + return find_max_mem_in_bytes(out) + + def main(argv): if len(argv) == 2: build_dir = sys.argv[1] @@ -222,6 +238,7 @@ def main(argv): # 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) + new_data["max_memory"] = run_max_mem_benchmark(deno_path) all_data.append(new_data) write_json(all_data_file, all_data) |