Skip to content
Permalink
Browse files

fix benchmark_test

  • Loading branch information...
ry committed Apr 15, 2019
1 parent b483ec6 commit f0119660e8c4f832d863c5e70eceb0589ec1fab7
Showing with 24 additions and 7 deletions.
  1. +8 −6 tools/benchmark.py
  2. +16 −1 tools/benchmark_test.py
@@ -155,17 +155,19 @@ def run_syscall_count_benchmark(deno_path):
return syscall_count_map


def find_max_mem_in_mb(out):
for row in out.split('\n'):
if 'maximum resident set size (kbytes)' in row.lower():
_, value = row.split(': ')
return int(value) / 1024
# 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 = tty_capture(cmd, '')[2]
return find_max_mem_in_mb(out)
return find_max_mem_in_bytes(out)


def main(argv):
17 tools/benchmark_test.py 100644 → 100755
@@ -1,7 +1,9 @@
#!/usr/bin/env python
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import sys
import os
import benchmark
from util import build_path, executable_suffix


def strace_parse_test():
@@ -23,7 +25,7 @@ def strace_parse_test():
def max_mem_parse_test():
with open(os.path.join(sys.path[0], "testdata/time.out"), "r") as f:
data = f.read()
assert benchmark.find_max_mem_in_mb(data) * 1024 == 120380
assert benchmark.find_max_mem_in_bytes(data) == 120380 * 1024


def binary_size_test(build_dir):
@@ -53,3 +55,16 @@ def benchmark_test(build_dir, deno_path):
if "linux" in sys.platform:
thread_count_test(deno_path)
syscall_count_test(deno_path)


# This test assumes tools/http_server.py is running in the background.
if __name__ == '__main__':
if len(sys.argv) == 2:
build_dir = sys.argv[1]
elif len(sys.argv) == 1:
build_dir = build_path()
else:
print "Usage: tools/benchmark_test.py [build_dir]"
sys.exit(1)
deno_exe = os.path.join(build_dir, "deno" + executable_suffix)
benchmark_test(build_dir, deno_exe)

0 comments on commit f011966

Please sign in to comment.
You can’t perform that action at this time.