summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorValentin Anger <syrupthinker@gryphno.de>2020-08-28 15:03:50 +0200
committerGitHub <noreply@github.com>2020-08-28 09:03:50 -0400
commit31f32ed8c4082d36ad2a4ea460366c0d57a5ddbc (patch)
tree2b60111cd53dd4034d1a92ee8caff89d164b7d2d /tools
parent3d23208019a2c9faaf265ff13ad59f2d04f10079 (diff)
Move benchmarks to Rust (#7134)
All benchmarks are done in Rust and can be invoked with `cargo bench`. Currently this has it's own "harness" that behaves like `./tools/benchmark.py` did. Because of this tests inside `cli/bench` are currently not run. This should be switched to the language provided harness once the `#[bench]` attribute has been stabilized.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/benchmark.py277
-rwxr-xr-xtools/benchmark_test.py66
-rw-r--r--tools/deno_http_proxy.ts20
-rw-r--r--tools/deno_tcp.ts29
-rw-r--r--tools/deno_tcp_proxy.ts30
-rwxr-xr-xtools/http_benchmark.py215
-rwxr-xr-xtools/lint.py1
-rw-r--r--tools/node_http.js9
-rw-r--r--tools/node_http_proxy.js22
-rw-r--r--tools/node_tcp.js18
-rw-r--r--tools/node_tcp_promise.js25
-rw-r--r--tools/node_tcp_proxy.js68
-rw-r--r--tools/testdata/strace_summary.out39
-rw-r--r--tools/testdata/strace_summary2.out37
-rw-r--r--tools/testdata/time.out18
-rw-r--r--tools/testdata/wrk1.txt14
-rw-r--r--tools/testdata/wrk2.txt13
-rw-r--r--tools/testdata/wrk3.txt13
-rwxr-xr-xtools/throughput_benchmark.py64
-rw-r--r--tools/util.py14
-rwxr-xr-xtools/util_test.py19
21 files changed, 2 insertions, 1009 deletions
diff --git a/tools/benchmark.py b/tools/benchmark.py
deleted file mode 100755
index 74a5fb665..000000000
--- a/tools/benchmark.py
+++ /dev/null
@@ -1,277 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2018-2020 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 target/debug/test_server and visit
-# http://localhost:4545/website
-
-import os
-import sys
-import json
-import time
-import tempfile
-import subprocess
-from util import build_path, executable_suffix, root_path, run, run_output
-import third_party
-from http_benchmark import http_benchmark
-import throughput_benchmark
-
-# The list of the tuples of the benchmark name, arguments and return code
-exec_time_benchmarks = [
- ("hello", ["run", "cli/tests/002_hello.ts"], None),
- ("relative_import", ["run", "cli/tests/003_relative_import.ts"], None),
- ("error_001", ["run", "cli/tests/error_001.ts"], 1),
- ("cold_hello", ["run", "--reload", "cli/tests/002_hello.ts"], None),
- ("cold_relative_import",
- ["run", "--reload", "cli/tests/003_relative_import.ts"], None),
- ("workers_startup",
- ["run", "--allow-read", "cli/tests/workers_startup_bench.ts"], None),
- ("workers_round_robin",
- ["run", "--allow-read", "cli/tests/workers_round_robin_bench.ts"], None),
- ("text_decoder", ["run", "cli/tests/text_decoder_perf.js"], None),
- ("text_encoder", ["run", "cli/tests/text_encoder_perf.js"], None),
- ("check", ["cache", "--reload", "std/examples/chat/server_test.ts"], None),
- ("no_check",
- ["cache", "--reload", "--no-check",
- "std/examples/chat/server_test.ts"], None),
-]
-
-
-def read_json(filename):
- with open(filename) as json_file:
- return json.load(json_file)
-
-
-def write_json(filename, data):
- with open(filename, 'w') as outfile:
- json.dump(data, outfile)
-
-
-def get_binary_sizes(build_dir):
- sizes = {}
- mtimes = {}
- # The deno executable should be located at the root of the build tree.
- deno_exe = os.path.join(build_dir, "deno" + executable_suffix)
- sizes["deno"] = os.path.getsize(deno_exe)
- # Because cargo's OUT_DIR is not predictable, search the build tree for
- # snapshot related files.
- for parent_dir, _, file_names in os.walk(build_dir):
- for file_name in file_names:
- if not file_name in [
- "CLI_SNAPSHOT.bin",
- "COMPILER_SNAPSHOT.bin",
- ]:
- continue
- file_path = os.path.join(parent_dir, file_name)
- file_mtime = os.path.getmtime(file_path)
- # If multiple copies of a file are found, use the most recent one.
- if file_name in mtimes and mtimes[file_name] > file_mtime:
- continue
- mtimes[file_name] = file_mtime
- sizes[file_name] = os.path.getsize(file_path)
- return sizes
-
-
-def get_strace_summary_text(test_args):
- f = tempfile.NamedTemporaryFile()
- cmd = ["strace", "-c", "-f", "-o", f.name] + test_args
- try:
- subprocess.check_output(cmd)
- except subprocess.CalledProcessError:
- pass
- return f.read()
-
-
-def strace_parse(summary_text):
- summary = {}
- # clear empty lines
- lines = list(filter(lambda x: x and x != "\n", summary_text.split("\n")))
- # Filter out non-relevant lines. See the error log at
- # https://github.com/denoland/deno/pull/3715/checks?check_run_id=397365887
- # This is checked in tools/testdata/strace_summary2.out
- lines = [x for x in lines if x.find("detached ...") == -1]
- if len(lines) < 4:
- return {} # malformed summary
- lines, total_line = lines[2:-2], lines[-1]
- # data to dict for each line
- for line in lines:
- syscall_fields = line.split()
- syscall_name = syscall_fields[-1]
- syscall_dict = {}
- if 5 <= len(syscall_fields) <= 6:
- syscall_dict = {
- "% time": float(syscall_fields[0]),
- "seconds": float(syscall_fields[1]),
- "usecs/call": int(syscall_fields[2]),
- "calls": int(syscall_fields[3])
- }
- syscall_dict["errors"] = 0 if len(syscall_fields) < 6 else int(
- syscall_fields[4])
- summary[syscall_name] = syscall_dict
- # record overall (total) data
- total_fields = total_line.split()
- summary["total"] = {
- "% time": float(total_fields[0]),
- "seconds": float(total_fields[1]),
- "calls": int(total_fields[2]),
- "errors": int(total_fields[3])
- }
- return summary
-
-
-def get_strace_summary(test_args):
- s = get_strace_summary_text(test_args)
- try:
- return strace_parse(s)
- except ValueError:
- print "error parsing strace"
- print "----- <strace> -------"
- print s
- print "----- </strace> ------"
-
-
-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
-
-
-# "thread_count" and "syscall_count" are both calculated here.
-def run_strace_benchmarks(deno_exe, new_data):
- thread_count = {}
- syscall_count = {}
- for (name, args, _) in exec_time_benchmarks:
- s = get_strace_summary([deno_exe] + args)
- thread_count[name] = s["clone"]["calls"] + 1
- syscall_count[name] = s["total"]["calls"]
- new_data["thread_count"] = thread_count
- new_data["syscall_count"] = syscall_count
-
-
-# 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_exe):
- results = {}
- for (name, args, return_code) in exec_time_benchmarks:
- cmd = ["/usr/bin/time", "-v", deno_exe] + args
- try:
- out = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- except subprocess.CalledProcessError as e:
- if (return_code is e.returncode):
- pass
- else:
- raise e
- mem = find_max_mem_in_bytes(out)
- results[name] = mem
- return results
-
-
-def run_exec_time(deno_exe, build_dir):
- hyperfine_exe = third_party.get_prebuilt_tool_path("hyperfine")
- benchmark_file = os.path.join(build_dir, "hyperfine_results.json")
-
- def benchmark_command(deno_exe, args, return_code):
- # Bash test which asserts the return code value of the previous command
- # $? contains the return code of the previous command
- return_code_test = "; test $? -eq {}".format(
- return_code) if return_code is not None else ""
- return "{} {}{}".format(deno_exe, " ".join(args), return_code_test)
-
- run([hyperfine_exe, "--export-json", benchmark_file, "--warmup", "3"] + [
- benchmark_command(deno_exe, args, return_code)
- for (_, args, return_code) in exec_time_benchmarks
- ])
- hyperfine_results = read_json(benchmark_file)
- results = {}
- for [[name, _, _], data] in zip(exec_time_benchmarks,
- hyperfine_results["results"]):
- results[name] = {
- "mean": data["mean"],
- "stddev": data["stddev"],
- "user": data["user"],
- "system": data["system"],
- "min": data["min"],
- "max": data["max"]
- }
- return results
-
-
-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()}
-
-
-def bundle_benchmark(deno_exe):
- bundles = {
- "file_server": "./std/http/file_server.ts",
- "gist": "./std/examples/gist.ts",
- }
-
- sizes = {}
-
- for name, url in bundles.items():
- # bundle
- path = name + ".bundle.js"
- run([deno_exe, "bundle", "--unstable", url, path])
- # get size of bundle
- assert os.path.exists(path)
- sizes[name] = os.path.getsize(path)
- # remove bundle
- os.remove(path)
-
- return sizes
-
-
-def main():
- build_dir = build_path()
- sha1 = run_output(["git", "rev-parse", "HEAD"],
- exit_on_fail=True).out.strip()
-
- deno_exe = os.path.join(build_dir, "deno")
-
- os.chdir(root_path)
-
- new_data = {
- "created_at": time.strftime("%Y-%m-%dT%H:%M:%SZ"),
- "sha1": sha1,
- }
-
- # TODO(ry) The "benchmark" benchmark should actually be called "exec_time".
- # When this is changed, the historical data in gh-pages branch needs to be
- # changed too.
- new_data["benchmark"] = run_exec_time(deno_exe, build_dir)
-
- new_data["binary_size"] = get_binary_sizes(build_dir)
- new_data["bundle_size"] = bundle_benchmark(deno_exe)
-
- # Cannot run throughput benchmark on windows because they don't have nc or
- # pipe.
- if os.name != 'nt':
- new_data["throughput"] = run_throughput(deno_exe)
- run_http(build_dir, new_data)
-
- if "linux" in sys.platform:
- run_strace_benchmarks(deno_exe, new_data)
- new_data["max_memory"] = run_max_mem_benchmark(deno_exe)
-
- print "===== <BENCHMARK RESULTS>"
- print json.dumps(new_data, indent=2)
- print "===== </BENCHMARK RESULTS>"
-
- write_json(os.path.join(build_dir, "bench.json"), new_data)
-
-
-if __name__ == '__main__':
- main()
diff --git a/tools/benchmark_test.py b/tools/benchmark_test.py
deleted file mode 100755
index efd4594b6..000000000
--- a/tools/benchmark_test.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import sys
-import os
-import unittest
-import benchmark
-from test_util import DenoTestCase, run_tests
-
-
-class TestBenchmark(DenoTestCase):
- def test_strace_parse(self):
- with open(
- os.path.join(sys.path[0], "testdata/strace_summary.out"),
- "r") as f:
- summary = benchmark.strace_parse(f.read())
- # first syscall line
- assert summary["munmap"]["calls"] == 60
- assert summary["munmap"]["errors"] == 0
- # line with errors
- assert summary["mkdir"]["errors"] == 2
- # last syscall line
- assert summary["prlimit64"]["calls"] == 2
- assert summary["prlimit64"]["% time"] == 0
- # summary line
- assert summary["total"]["calls"] == 704
-
- def test_strace_parse2(self):
- with open(
- os.path.join(sys.path[0], "testdata/strace_summary2.out"),
- "r") as f:
- summary = benchmark.strace_parse(f.read())
- # first syscall line
- assert summary["futex"]["calls"] == 449
- assert summary["futex"]["errors"] == 94
- # summary line
- assert summary["total"]["calls"] == 821
-
- def test_max_mem_parse(self):
- with open(os.path.join(sys.path[0], "testdata/time.out"), "r") as f:
- data = f.read()
- assert benchmark.find_max_mem_in_bytes(data) == 120380 * 1024
-
- def test_binary_size(self):
- binary_size_dict = benchmark.get_binary_sizes(self.build_dir)
- assert binary_size_dict["deno"] > 0
- assert binary_size_dict["CLI_SNAPSHOT.bin"] > 0
-
- @unittest.skipIf("linux" not in sys.platform,
- "strace only supported on linux")
- def test_strace(self):
- new_data = {}
- benchmark.run_strace_benchmarks(self.deno_exe, new_data)
- assert "thread_count" in new_data
- assert "syscall_count" in new_data
-
- s = new_data["thread_count"]
- assert "hello" in s
- assert s["hello"] > 1
-
- s = new_data["syscall_count"]
- assert "hello" in s
- assert s["hello"] > 1
-
-
-if __name__ == '__main__':
- run_tests()
diff --git a/tools/deno_http_proxy.ts b/tools/deno_http_proxy.ts
deleted file mode 100644
index 6e5141377..000000000
--- a/tools/deno_http_proxy.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import { serve, ServerRequest } from "../std/http/server.ts";
-
-const addr = Deno.args[0] || "127.0.0.1:4500";
-const originAddr = Deno.args[1] || "127.0.0.1:4501";
-const server = serve(addr);
-
-async function proxyRequest(req: ServerRequest): Promise<void> {
- const url = `http://${originAddr}${req.url}`;
- const resp = await fetch(url, {
- method: req.method,
- headers: req.headers,
- });
- req.respond(resp);
-}
-
-console.log(`Proxy listening on http://${addr}/`);
-for await (const req of server) {
- proxyRequest(req);
-}
diff --git a/tools/deno_tcp.ts b/tools/deno_tcp.ts
deleted file mode 100644
index 898869768..000000000
--- a/tools/deno_tcp.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-// Used for benchmarking Deno's networking. See tools/http_benchmark.py
-// TODO Replace this with a real HTTP server once
-// https://github.com/denoland/deno/issues/726 is completed.
-// Note: this is a keep-alive server.
-const addr = Deno.args[0] || "127.0.0.1:4500";
-const [hostname, port] = addr.split(":");
-const listener = Deno.listen({ hostname, port: Number(port) });
-const response = new TextEncoder().encode(
- "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n",
-);
-async function handle(conn: Deno.Conn): Promise<void> {
- const buffer = new Uint8Array(1024);
- try {
- while (true) {
- const r = await conn.read(buffer);
- if (r === null) {
- break;
- }
- await conn.write(response);
- }
- } finally {
- conn.close();
- }
-}
-
-console.log("Listening on", addr);
-for await (const conn of listener) {
- handle(conn);
-}
diff --git a/tools/deno_tcp_proxy.ts b/tools/deno_tcp_proxy.ts
deleted file mode 100644
index a9832e363..000000000
--- a/tools/deno_tcp_proxy.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-// Used for benchmarking Deno's tcp proxy performance. See tools/http_benchmark.py
-const addr = Deno.args[0] || "127.0.0.1:4500";
-const originAddr = Deno.args[1] || "127.0.0.1:4501";
-
-const [hostname, port] = addr.split(":");
-const [originHostname, originPort] = originAddr.split(":");
-
-const listener = Deno.listen({ hostname, port: Number(port) });
-
-async function handle(conn: Deno.Conn): Promise<void> {
- const origin = await Deno.connect({
- hostname: originHostname,
- port: Number(originPort),
- });
- try {
- await Promise.all([Deno.copy(conn, origin), Deno.copy(origin, conn)]);
- } catch (err) {
- if (err.message !== "read error" && err.message !== "write error") {
- throw err;
- }
- } finally {
- conn.close();
- origin.close();
- }
-}
-
-console.log(`Proxy listening on http://${addr}/`);
-for await (const conn of listener) {
- handle(conn);
-}
diff --git a/tools/http_benchmark.py b/tools/http_benchmark.py
deleted file mode 100755
index 17420fe84..000000000
--- a/tools/http_benchmark.py
+++ /dev/null
@@ -1,215 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import os
-import sys
-import time
-import subprocess
-import util
-import third_party
-
-# Some of the benchmarks in this file have been renamed. In case the history
-# somehow gets messed up:
-# "node_http" was once called "node"
-# "deno_tcp" was once called "deno"
-# "deno_http" was once called "deno_net_http"
-
-DURATION = "20s"
-NEXT_PORT = 4544
-
-
-def server_addr(port):
- return "0.0.0.0:%s" % port
-
-
-def get_port():
- global NEXT_PORT
- port = NEXT_PORT
- NEXT_PORT += 1
- # Return port as str because all usages below are as a str and having it an
- # integer just adds complexity.
- return str(port)
-
-
-def deno_tcp(deno_exe):
- port = get_port()
- deno_cmd = [
- # TODO(lucacasonato): remove unstable when stabilized
- deno_exe,
- "run",
- "--allow-net",
- "tools/deno_tcp.ts",
- server_addr(port)
- ]
- print "http_benchmark testing DENO tcp."
- return run(deno_cmd, port)
-
-
-def deno_http(deno_exe):
- port = get_port()
- deno_cmd = [
- deno_exe, "run", "--allow-net", "--reload", "--unstable",
- "std/http/http_bench.ts",
- server_addr(port)
- ]
- print "http_benchmark testing DENO using net/http."
- return run(deno_cmd, port)
-
-
-def deno_tcp_proxy(deno_exe, hyper_hello_exe):
- port = get_port()
- origin_port = get_port()
- deno_cmd = [
- deno_exe, "run", "--allow-net", "tools/deno_tcp_proxy.ts",
- server_addr(port),
- server_addr(origin_port)
- ]
- print "http_proxy_benchmark testing DENO using net/tcp."
- return run(
- deno_cmd,
- port,
- origin_cmd=http_proxy_origin(hyper_hello_exe, origin_port))
-
-
-def deno_http_proxy(deno_exe, hyper_hello_exe):
- port = get_port()
- origin_port = get_port()
- deno_cmd = [
- deno_exe, "run", "--allow-net", "tools/deno_http_proxy.ts",
- server_addr(port),
- server_addr(origin_port)
- ]
- print "http_proxy_benchmark testing DENO using net/http."
- return run(
- deno_cmd,
- port,
- origin_cmd=http_proxy_origin(hyper_hello_exe, origin_port))
-
-
-def core_http_bin_ops(exe):
- print "http_benchmark testing CORE http_bench_bin_ops"
- return run([exe], 4544)
-
-
-def core_http_json_ops(exe):
- print "http_benchmark testing CORE http_bench_json_ops"
- return run([exe], 4544)
-
-
-def node_http():
- port = get_port()
- node_cmd = ["node", "tools/node_http.js", port]
- print "http_benchmark testing NODE."
- return run(node_cmd, port)
-
-
-def node_http_proxy(hyper_hello_exe):
- port = get_port()
- origin_port = get_port()
- node_cmd = ["node", "tools/node_http_proxy.js", port, origin_port]
- print "http_proxy_benchmark testing NODE."
- return run(node_cmd, port, None,
- http_proxy_origin(hyper_hello_exe, origin_port))
-
-
-def node_tcp_proxy(hyper_hello_exe):
- port = get_port()
- origin_port = get_port()
- node_cmd = ["node", "tools/node_tcp_proxy.js", port, origin_port]
- print "http_proxy_benchmark testing NODE tcp."
- return run(node_cmd, port, None,
- http_proxy_origin(hyper_hello_exe, origin_port))
-
-
-def node_tcp():
- port = get_port()
- node_cmd = ["node", "tools/node_tcp.js", port]
- print "http_benchmark testing node_tcp.js"
- return run(node_cmd, port)
-
-
-def http_proxy_origin(hyper_hello_exe, port):
- return [hyper_hello_exe, port]
-
-
-def hyper_http(hyper_hello_exe):
- port = get_port()
- hyper_cmd = [hyper_hello_exe, port]
- print "http_benchmark testing RUST hyper."
- return run(hyper_cmd, port)
-
-
-def http_benchmark(build_dir):
- deno_exe = os.path.join(build_dir, "deno")
- hyper_hello_exe = os.path.join(build_dir, "test_server")
- core_http_bin_ops_exe = os.path.join(build_dir,
- "examples/http_bench_bin_ops")
- core_http_json_ops_exe = os.path.join(build_dir,
- "examples/http_bench_json_ops")
- return {
- # "deno_tcp" was once called "deno"
- "deno_tcp": deno_tcp(deno_exe),
- # "deno_udp": deno_udp(deno_exe),
- "deno_http": deno_http(deno_exe),
- # TODO(ry) deno_proxy disabled to make fetch() standards compliant.
- # "deno_proxy": deno_http_proxy(deno_exe, hyper_hello_exe),
- "deno_proxy_tcp": deno_tcp_proxy(deno_exe, hyper_hello_exe),
- # "core_http_bin_ops" was once called "deno_core_single"
- # "core_http_bin_ops" was once called "deno_core_http_bench"
- "core_http_bin_ops": core_http_bin_ops(core_http_bin_ops_exe),
- "core_http_json_ops": core_http_json_ops(core_http_json_ops_exe),
- # "node_http" was once called "node"
- "node_http": node_http(),
- "node_proxy": node_http_proxy(hyper_hello_exe),
- "node_proxy_tcp": node_tcp_proxy(hyper_hello_exe),
- "node_tcp": node_tcp(),
- "hyper": hyper_http(hyper_hello_exe)
- }
-
-
-def run(server_cmd, port, merge_env=None, origin_cmd=None):
-
- # Run deno echo server in the background.
- if merge_env is None:
- env = None
- else:
- env = os.environ.copy()
- for key, value in merge_env.iteritems():
- env[key] = value
-
- # Wait for port 4544 to become available.
- # TODO Need to use SO_REUSEPORT with tokio::net::TcpListener.
- time.sleep(5)
-
- origin = None
- if origin_cmd is not None:
- origin = subprocess.Popen(origin_cmd, env=env)
-
- print server_cmd
- server = subprocess.Popen(server_cmd, env=env)
-
- time.sleep(5) # wait for server to wake up. TODO racy.
-
- try:
- wrk = third_party.get_prebuilt_tool_path("wrk")
- assert os.path.exists(wrk)
- cmd = "%s -d %s --latency http://127.0.0.1:%s/" % (wrk, DURATION, port)
- print cmd
- output = subprocess.check_output(cmd, shell=True)
- stats = util.parse_wrk_output(output)
- print output
- return stats
- finally:
- server_retcode = server.poll()
- if server_retcode is not None and server_retcode != 0:
- print "server ended with error"
- sys.exit(1)
- server.kill()
- if origin is not None:
- origin.kill()
-
-
-if __name__ == '__main__':
- if len(sys.argv) < 2:
- print "Usage ./tools/http_benchmark.py target/debug/deno"
- sys.exit(1)
- deno_http(sys.argv[1])
diff --git a/tools/lint.py b/tools/lint.py
index 5891ba9f9..e7f967140 100755
--- a/tools/lint.py
+++ b/tools/lint.py
@@ -72,6 +72,7 @@ def eslint():
":!:cli/tests/encoding/**",
":!:cli/dts/**",
":!:cli/tsc/*typescript.js",
+ ":!:cli/bench/node*.js",
])
if source_files:
max_command_len = 30000
diff --git a/tools/node_http.js b/tools/node_http.js
deleted file mode 100644
index 189098e4c..000000000
--- a/tools/node_http.js
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-const http = require("http");
-const port = process.argv[2] || "4544";
-console.log("port", port);
-http
- .Server((req, res) => {
- res.end("Hello World");
- })
- .listen(port);
diff --git a/tools/node_http_proxy.js b/tools/node_http_proxy.js
deleted file mode 100644
index b984c484f..000000000
--- a/tools/node_http_proxy.js
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-const http = require("http");
-const port = process.argv[2] || "4544";
-const originPort = process.argv[3] || "4545";
-console.log("port", port);
-http
- .Server((req, res) => {
- const options = {
- port: originPort,
- path: req.url,
- method: req.method,
- headers: req.headers,
- };
-
- const proxy = http.request(options, (proxyRes) => {
- res.writeHead(proxyRes.statusCode, proxyRes.headers);
- proxyRes.pipe(res, { end: true });
- });
-
- req.pipe(proxy, { end: true });
- })
- .listen(port);
diff --git a/tools/node_tcp.js b/tools/node_tcp.js
deleted file mode 100644
index 22e2a5161..000000000
--- a/tools/node_tcp.js
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-// Note: this is a keep-alive server.
-const { Server } = require("net");
-const port = process.argv[2] || "4544";
-console.log("port", port);
-
-const response = Buffer.from(
- "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n",
-);
-
-Server((socket) => {
- socket.on("data", (_) => {
- socket.write(response);
- });
- socket.on("error", (_) => {
- socket.destroy();
- });
-}).listen(port);
diff --git a/tools/node_tcp_promise.js b/tools/node_tcp_promise.js
deleted file mode 100644
index 36709d2b9..000000000
--- a/tools/node_tcp_promise.js
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-// Note: this is a keep-alive server.
-const { Server } = require("net");
-const port = process.argv[2] || "4544";
-console.log("port", port);
-
-const response = Buffer.from(
- "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n",
-);
-
-function write(socket, buffer) {
- const p = new Promise((resolve, _) => {
- socket.write(buffer, resolve);
- });
- return Promise.resolve(p);
-}
-
-Server(async (socket) => {
- socket.on("error", (_) => {
- socket.destroy();
- });
- for await (const _ of socket) {
- await write(socket, response);
- }
-}).listen(port);
diff --git a/tools/node_tcp_proxy.js b/tools/node_tcp_proxy.js
deleted file mode 100644
index d693dc5c8..000000000
--- a/tools/node_tcp_proxy.js
+++ /dev/null
@@ -1,68 +0,0 @@
-const net = require("net");
-
-process.on("uncaughtException", function (error) {
- console.error(error);
-});
-
-if (process.argv.length != 4) {
- console.log("usage: %s <localport> <remoteport>", process.argv[1]);
- process.exit();
-}
-
-const localport = process.argv[2];
-const remoteport = process.argv[3];
-
-const remotehost = "127.0.0.1";
-
-const server = net.createServer(function (localsocket) {
- const remotesocket = new net.Socket();
-
- remotesocket.connect(remoteport, remotehost);
-
- localsocket.on("data", function (data) {
- const flushed = remotesocket.write(data);
- if (!flushed) {
- localsocket.pause();
- }
- });
-
- remotesocket.on("data", function (data) {
- const flushed = localsocket.write(data);
- if (!flushed) {
- remotesocket.pause();
- }
- });
-
- localsocket.on("drain", function () {
- remotesocket.resume();
- });
-
- remotesocket.on("drain", function () {
- localsocket.resume();
- });
-
- localsocket.on("close", function () {
- remotesocket.end();
- });
-
- remotesocket.on("close", function () {
- localsocket.end();
- });
-
- localsocket.on("error", function () {
- localsocket.end();
- });
-
- remotesocket.on("error", function () {
- remotesocket.end();
- });
-});
-
-server.listen(localport);
-
-console.log(
- "redirecting connections from 127.0.0.1:%d to %s:%d",
- localport,
- remotehost,
- remoteport,
-);
diff --git a/tools/testdata/strace_summary.out b/tools/testdata/strace_summary.out
deleted file mode 100644
index 7984b175a..000000000
--- a/tools/testdata/strace_summary.out
+++ /dev/null
@@ -1,39 +0,0 @@
-% time seconds usecs/call calls errors syscall
------- ----------- ----------- --------- --------- ----------------
- 65.76 0.005881 98 60 munmap
- 13.79 0.001233 2 462 mprotect
- 7.13 0.000638 11 56 mmap
- 3.57 0.000319 22 14 openat
- 1.65 0.000148 10 14 fstat
- 1.58 0.000141 7 20 read
- 1.53 0.000137 7 18 close
- 1.49 0.000133 16 8 madvise
- 1.10 0.000098 98 1 execve
- 0.30 0.000027 9 3 prctl
- 0.29 0.000026 26 1 1 access
- 0.25 0.000022 11 2 2 mkdir
- 0.23 0.000021 7 3 write
- 0.18 0.000016 4 4 set_robust_list
- 0.16 0.000014 7 2 brk
- 0.15 0.000013 13 1 pipe2
- 0.11 0.000010 3 3 clone
- 0.11 0.000010 3 3 sigaltstack
- 0.10 0.000009 4 2 stat
- 0.10 0.000009 9 1 arch_prctl
- 0.10 0.000009 9 1 epoll_create1
- 0.09 0.000008 8 1 epoll_ctl
- 0.08 0.000007 3 2 getrandom
- 0.04 0.000004 4 1 getcwd
- 0.04 0.000004 2 2 sched_getaffinity
- 0.03 0.000003 3 1 1 ioctl
- 0.03 0.000003 1 3 futex
- 0.00 0.000000 0 1 open
- 0.00 0.000000 0 5 rt_sigaction
- 0.00 0.000000 0 1 rt_sigprocmask
- 0.00 0.000000 0 1 fcntl
- 0.00 0.000000 0 1 1 readlink
- 0.00 0.000000 0 1 set_tid_address
- 0.00 0.000000 0 3 epoll_wait
- 0.00 0.000000 0 2 prlimit64
------- ----------- ----------- --------- --------- ----------------
-100.00 0.008943 704 5 total
diff --git a/tools/testdata/strace_summary2.out b/tools/testdata/strace_summary2.out
deleted file mode 100644
index 798a06665..000000000
--- a/tools/testdata/strace_summary2.out
+++ /dev/null
@@ -1,37 +0,0 @@
-17697 ????( <detached ...>
-% time seconds usecs/call calls errors syscall
------- ----------- ----------- --------- --------- ----------------
- 63.19 0.030363 68 449 94 futex
- 34.70 0.016672 16672 1 epoll_wait
- 1.58 0.000761 6 129 mprotect
- 0.40 0.000193 3 58 madvise
- 0.11 0.000055 3 17 brk
- 0.01 0.000003 0 32 mmap
- 0.00 0.000000 0 20 1 read
- 0.00 0.000000 0 1 write
- 0.00 0.000000 0 14 open
- 0.00 0.000000 0 17 close
- 0.00 0.000000 0 10 fstat
- 0.00 0.000000 0 10 munmap
- 0.00 0.000000 0 5 rt_sigaction
- 0.00 0.000000 0 1 rt_sigprocmask
- 0.00 0.000000 0 4 4 ioctl
- 0.00 0.000000 0 8 8 access
- 0.00 0.000000 0 6 sched_yield
- 0.00 0.000000 0 3 clone
- 0.00 0.000000 0 1 execve
- 0.00 0.000000 0 3 fcntl
- 0.00 0.000000 0 5 getcwd
- 0.00 0.000000 0 2 getrlimit
- 0.00 0.000000 0 9 sigaltstack
- 0.00 0.000000 0 3 prctl
- 0.00 0.000000 0 1 arch_prctl
- 0.00 0.000000 0 3 sched_getaffinity
- 0.00 0.000000 0 1 set_tid_address
- 0.00 0.000000 0 1 epoll_ctl
- 0.00 0.000000 0 4 set_robust_list
- 0.00 0.000000 0 1 epoll_create1
- 0.00 0.000000 0 1 pipe2
- 0.00 0.000000 0 1 getrandom
------- ----------- ----------- --------- --------- ----------------
-100.00 0.048047 821 107 total
diff --git a/tools/testdata/time.out b/tools/testdata/time.out
deleted file mode 100644
index 3ff409bd7..000000000
--- a/tools/testdata/time.out
+++ /dev/null
@@ -1,18 +0,0 @@
-Hello
- Command being timed: "./target/debug/deno tests/003_relative_import.ts"
- User time (seconds): 2.43
- System time (seconds): 0.05
- Percent of CPU this job got: 156%
- Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.59
- Average shared text size (kbytes): 0
- Average unshared data size (kbytes): 0
- Average stack size (kbytes): 0
- Average total size (kbytes): 0
- Maximum resident set size (kbytes): 120380
- Average resident set size (kbytes): 0
- Major (requiring I/O) page faults: 0
- Minor (reclaiming a frame) page faults: 41452
- Voluntary context switches: 75
- Involuntary context switches: 42
- Swaps: 0
- File system inputs: 0 \ No newline at end of file
diff --git a/tools/testdata/wrk1.txt b/tools/testdata/wrk1.txt
deleted file mode 100644
index 8ad7cf739..000000000
--- a/tools/testdata/wrk1.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-Running 10s test @ http://127.0.0.1:4500/
- 2 threads and 10 connections
- Thread Stats Avg Stdev Max +/- Stdev
- Latency 5.08ms 1.37ms 34.96ms 96.63%
- Req/Sec 0.92k 51.83 1.00k 78.50%
- Latency Distribution
- 50% 1.96ms
- 75% 2.02ms
- 90% 2.43ms
- 99% 6.25ms
- 18381 requests in 10.00s, 0.89MB read
- Socket errors: connect 0, read 18381, write 0, timeout 0
-Requests/sec: 1837.86
-Transfer/sec: 91.53KB
diff --git a/tools/testdata/wrk2.txt b/tools/testdata/wrk2.txt
deleted file mode 100644
index 4b68c6c8a..000000000
--- a/tools/testdata/wrk2.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-Running 10s test @ http://127.0.0.1:4544/
- 2 threads and 10 connections
- Thread Stats Avg Stdev Max +/- Stdev
- Latency 402.90us 1.15ms 1.25us 94.86%
- Req/Sec 26.86k 2.01k 31.81k 78.71%
- Latency Distribution
- 50% 2.03ms
- 75% 2.10ms
- 90% 2.43ms
- 99% 6.22ms
- 539721 requests in 10.10s, 26.25MB read
-Requests/sec: 53435.75
-Transfer/sec: 2.60MB
diff --git a/tools/testdata/wrk3.txt b/tools/testdata/wrk3.txt
deleted file mode 100644
index 4c115a096..000000000
--- a/tools/testdata/wrk3.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-Running 10s test @ http://127.0.0.1:4544/
- 2 threads and 10 connections
- Thread Stats Avg Stdev Max +/- Stdev
- Latency 26.55ms 152.26ms 1.63s 97.45%
- Req/Sec 48.26k 3.13k 61.41k 93.00%
- Latency Distribution
- 50% 1.98ms
- 75% 2.06ms
- 90% 2.47ms
- 99% 6.36ms
- 960491 requests in 10.00s, 80.61MB read
-Requests/sec: 96037.58
-Transfer/sec: 8.06MB
diff --git a/tools/throughput_benchmark.py b/tools/throughput_benchmark.py
deleted file mode 100755
index f5b9f2db2..000000000
--- a/tools/throughput_benchmark.py
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2018-2020 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 target/debug/test_server and visit
-# http://localhost:4545/website
-
-import os
-import sys
-import time
-import subprocess
-import util
-
-MB = 1024 * 1024
-SERVER_ADDR = "0.0.0.0:4544"
-CLIENT_ADDR = "127.0.0.1 4544"
-
-
-def cat(deno_exe, megs):
- size = megs * MB
- start = time.time()
- cmd = deno_exe + " run --allow-read "
- cmd += "cli/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.
- args = [
- deno_exe, "run", "--allow-net", "cli/tests/echo_server.ts", SERVER_ADDR
- ]
- print args
- echo_server = subprocess.Popen(args)
-
- time.sleep(5) # wait for deno to wake up. TODO racy.
- try:
- start = time.time()
- nc_cmd = "nc " + CLIENT_ADDR
- cmd = ("head -c %s /dev/zero " % size) + " | " + nc_cmd
- print cmd
- subprocess.check_output(cmd, shell=True)
- end = time.time()
- return end - start
- finally:
- echo_server.kill()
-
-
-def main():
- deno_exe = sys.argv[1]
- megs = int(sys.argv[2])
- if not deno_exe or not megs:
- print "Usage ./tools/throughput_benchmark.py target/debug/deno 100"
- sys.exit(1)
- secs = tcp(sys.argv[1], megs)
- print secs, "seconds"
-
-
-if __name__ == '__main__':
- main()
diff --git a/tools/util.py b/tools/util.py
index 889afae82..7cae4f84c 100644
--- a/tools/util.py
+++ b/tools/util.py
@@ -361,20 +361,6 @@ def extract_max_latency_in_milliseconds(pattern, string):
return num * 1000
-def parse_wrk_output(output):
- stats = {}
- stats['req_per_sec'] = None
- stats['max_latency'] = None
- for line in output.split("\n"):
- if stats['req_per_sec'] is None:
- stats['req_per_sec'] = extract_number(r'Requests/sec:\s+(\d+)',
- line)
- if stats['max_latency'] is None:
- stats['max_latency'] = extract_max_latency_in_milliseconds(
- r'\s+99%(?:\s+(\d+.\d+)([a-z]+))', line)
- return stats
-
-
def platform():
return {"linux2": "linux", "darwin": "mac", "win32": "win"}[sys.platform]
diff --git a/tools/util_test.py b/tools/util_test.py
index 8c25b10ed..7ad9b415e 100755
--- a/tools/util_test.py
+++ b/tools/util_test.py
@@ -2,8 +2,7 @@
import os
from test_util import DenoTestCase, run_tests
-from util import (parse_exit_code, shell_quote_win, parse_wrk_output,
- root_path)
+from util import (parse_exit_code, shell_quote_win, root_path)
class TestUtil(DenoTestCase):
@@ -21,22 +20,6 @@ class TestUtil(DenoTestCase):
assert shell_quote_win(
'a"b""c\\d\\"e\\\\') == '"a""b""""c\\d\\\\""e\\\\\\\\"'
- def test_parse_wrk_output(self):
- f = open(os.path.join(root_path, "tools/testdata/wrk1.txt"))
- stats = parse_wrk_output(f.read())
- assert stats['req_per_sec'] == 1837
- assert stats['max_latency'] == 6.25
-
- f2 = open(os.path.join(root_path, "tools/testdata/wrk2.txt"))
- stats2 = parse_wrk_output(f2.read())
- assert stats2['req_per_sec'] == 53435
- assert stats2['max_latency'] == 6.22
-
- f3 = open(os.path.join(root_path, "tools/testdata/wrk3.txt"))
- stats3 = parse_wrk_output(f3.read())
- assert stats3['req_per_sec'] == 96037
- assert stats3['max_latency'] == 6.36
-
def test_executable_exists(self):
assert os.path.exists(self.deno_exe)