diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/benchmark.py | 4 | ||||
-rwxr-xr-x | tools/format.py | 4 | ||||
-rwxr-xr-x | tools/http_benchmark.py | 20 | ||||
-rwxr-xr-x | tools/lint.py | 4 | ||||
-rw-r--r-- | tools/node_tcp_promise.js | 25 | ||||
-rwxr-xr-x | tools/test.py | 5 |
6 files changed, 56 insertions, 6 deletions
diff --git a/tools/benchmark.py b/tools/benchmark.py index c9a3e0243..53037b1e7 100755 --- a/tools/benchmark.py +++ b/tools/benchmark.py @@ -204,8 +204,10 @@ def main(argv): # 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) + 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) diff --git a/tools/format.py b/tools/format.py index fe053eaa3..083640c22 100755 --- a/tools/format.py +++ b/tools/format.py @@ -39,7 +39,7 @@ qrun( print "prettier" qrun(["node", prettier, "--write", "--loglevel=error"] + ["rollup.config.js"] + glob("*.json") + glob("*.md") + - find_exts([".github", "js", "tests", "tools", "website"], + find_exts([".github", "js", "tests", "tools", "website", "core"], [".js", ".json", ".ts", ".md"], skip=["tools/clang", "js/deps"])) @@ -47,4 +47,4 @@ print "rustfmt" qrun([ "third_party/rustfmt/" + platform() + "/rustfmt", "--config-path", rustfmt_config, "build.rs" -] + find_exts(["src"], [".rs"])) +] + find_exts(["src", "core"], [".rs"])) diff --git a/tools/http_benchmark.py b/tools/http_benchmark.py index 312e61da6..d84a24de6 100755 --- a/tools/http_benchmark.py +++ b/tools/http_benchmark.py @@ -30,6 +30,16 @@ def deno_net_http_benchmark(deno_exe): }) +def deno_core_single(exe): + print "http_benchmark testing deno_core_single" + return run([exe, "--single-thread"]) + + +def deno_core_multi(exe): + print "http_benchmark testing deno_core_multi" + return run([exe, "--multi-thread"]) + + def node_http_benchmark(): node_cmd = ["node", "tools/node_http.js", ADDR.split(":")[1]] print "http_benchmark testing NODE." @@ -48,11 +58,13 @@ def hyper_http_benchmark(hyper_hello_exe): return run(hyper_cmd) -def http_benchmark(deno_exe, hyper_hello_exe): +def http_benchmark(deno_exe, hyper_hello_exe, core_http_bench_exe): r = {} # TODO Rename to "deno_tcp" r["deno"] = deno_http_benchmark(deno_exe) r["deno_net_http"] = deno_net_http_benchmark(deno_exe) + r["deno_core_single"] = deno_core_single(core_http_bench_exe) + r["deno_core_multi"] = deno_core_multi(core_http_bench_exe) r["node"] = node_http_benchmark() r["node_tcp"] = node_tcp_benchmark() r["hyper"] = hyper_http_benchmark(hyper_hello_exe) @@ -68,8 +80,14 @@ def run(server_cmd, merge_env=None): 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) + server = subprocess.Popen(server_cmd, env=env) + time.sleep(5) # wait for server to wake up. TODO racy. + try: cmd = "third_party/wrk/%s/wrk -d %s http://%s/" % (util.platform(), DURATION, ADDR) diff --git a/tools/lint.py b/tools/lint.py index 148cc4728..e3e765387 100755 --- a/tools/lint.py +++ b/tools/lint.py @@ -21,8 +21,8 @@ run([ run(["node", tslint, "-p", ".", "--exclude", "**/gen/**/*.ts"]) run([ - "node", tslint, "./js/**/*_test.ts", "./tests/**/*.ts", "--exclude", - "**/gen/**/*.ts", "--project", "tsconfig.json" + "node", tslint, "./js/**/*_test.ts", "./tests/**/*.ts", "./core/*.js", + "--exclude", "**/gen/**/*.ts", "--project", "tsconfig.json" ]) run([sys.executable, "third_party/depot_tools/pylint.py"] + diff --git a/tools/node_tcp_promise.js b/tools/node_tcp_promise.js new file mode 100644 index 000000000..c8fc54aba --- /dev/null +++ b/tools/node_tcp_promise.js @@ -0,0 +1,25 @@ +// Copyright 2018-2019 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" +); + +async function write(socket, buffer) { + let p = new Promise((resolve, reject) => { + socket.write(buffer, resolve); + }); + return p; +} + +Server(async socket => { + socket.on("error", _ => { + socket.destroy(); + }); + for await (const data of socket) { + write(socket, response); + } +}).listen(port); diff --git a/tools/test.py b/tools/test.py index 5d08e59d1..5a8c67519 100755 --- a/tools/test.py +++ b/tools/test.py @@ -85,6 +85,11 @@ def main(argv): check_exists(test_rs) run([test_rs]) + deno_core_test = os.path.join(build_dir, + "deno_core_test" + executable_suffix) + check_exists(deno_core_test) + run([deno_core_test]) + unit_tests(deno_exe) prefetch_test(deno_exe) |