Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add benchmark for net/http #1289

Merged
merged 2 commits into from Dec 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -15,3 +15,4 @@ node_modules
# temp benchmark data
/website/data.json
/website/recent.json
/js/gen
3 changes: 3 additions & 0 deletions .gitmodules
Expand Up @@ -5,3 +5,6 @@
path = build
url = https://github.com/denoland/chromium_build.git
branch = deno
[submodule "js/deps/https/deno.land/x/net"]
path = js/deps/https/deno.land/x/net
url = https://github.com/denoland/deno_net.git
1 change: 1 addition & 0 deletions js/deps/https/deno.land/x/net
Submodule net added at 958dad
28 changes: 25 additions & 3 deletions tools/http_benchmark.py
Expand Up @@ -16,6 +16,20 @@ def deno_http_benchmark(deno_exe):
return run(deno_cmd)


def deno_net_http_benchmark(deno_exe):
deno_cmd = [
deno_exe, "--allow-net", "js/deps/https/deno.land/x/net/http_bench.ts",
ADDR
]
print "http_benchmark testing DENO using net/http."
return run(
deno_cmd,
merge_env={
# Load from //js/deps/https/deno.land/net/ submodule.
"DENO_DIR": os.path.join(util.root_path, "js")
})


def node_http_benchmark():
node_cmd = ["node", "tools/node_http.js", ADDR.split(":")[1]]
print "http_benchmark testing NODE."
Expand All @@ -38,15 +52,23 @@ def http_benchmark(deno_exe, hyper_hello_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["node"] = node_http_benchmark()
r["node_tcp"] = node_tcp_benchmark()
r["hyper"] = hyper_http_benchmark(hyper_hello_exe)
return r


def run(server_cmd):
def run(server_cmd, merge_env=None):
# Run deno echo server in the background.
server = subprocess.Popen(server_cmd)
if merge_env is None:
env = None
else:
env = os.environ.copy()
for key, value in merge_env.iteritems():
env[key] = value

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(),
Expand All @@ -64,4 +86,4 @@ def run(server_cmd):
if len(sys.argv) < 2:
print "Usage ./tools/http_benchmark.py target/debug/deno"
sys.exit(1)
deno_http_benchmark(sys.argv[1])
deno_net_http_benchmark(sys.argv[1])