mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
Add benchmark for net/http (#1289)
This commit is contained in:
parent
0d3584cf46
commit
ba429ccde8
4 changed files with 30 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -15,3 +15,4 @@ node_modules
|
||||||
# temp benchmark data
|
# temp benchmark data
|
||||||
/website/data.json
|
/website/data.json
|
||||||
/website/recent.json
|
/website/recent.json
|
||||||
|
/js/gen
|
||||||
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -5,3 +5,6 @@
|
||||||
path = build
|
path = build
|
||||||
url = https://github.com/denoland/chromium_build.git
|
url = https://github.com/denoland/chromium_build.git
|
||||||
branch = deno
|
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
js/deps/https/deno.land/x/net
Submodule
1
js/deps/https/deno.land/x/net
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 958dadc8752f1aface8cff39c56011b016fb1460
|
|
@ -16,6 +16,20 @@ def deno_http_benchmark(deno_exe):
|
||||||
return run(deno_cmd)
|
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():
|
def node_http_benchmark():
|
||||||
node_cmd = ["node", "tools/node_http.js", ADDR.split(":")[1]]
|
node_cmd = ["node", "tools/node_http.js", ADDR.split(":")[1]]
|
||||||
print "http_benchmark testing NODE."
|
print "http_benchmark testing NODE."
|
||||||
|
@ -38,15 +52,23 @@ def http_benchmark(deno_exe, hyper_hello_exe):
|
||||||
r = {}
|
r = {}
|
||||||
# TODO Rename to "deno_tcp"
|
# TODO Rename to "deno_tcp"
|
||||||
r["deno"] = deno_http_benchmark(deno_exe)
|
r["deno"] = deno_http_benchmark(deno_exe)
|
||||||
|
r["deno_net_http"] = deno_net_http_benchmark(deno_exe)
|
||||||
r["node"] = node_http_benchmark()
|
r["node"] = node_http_benchmark()
|
||||||
r["node_tcp"] = node_tcp_benchmark()
|
r["node_tcp"] = node_tcp_benchmark()
|
||||||
r["hyper"] = hyper_http_benchmark(hyper_hello_exe)
|
r["hyper"] = hyper_http_benchmark(hyper_hello_exe)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
def run(server_cmd):
|
def run(server_cmd, merge_env=None):
|
||||||
# Run deno echo server in the background.
|
# 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.
|
time.sleep(5) # wait for server to wake up. TODO racy.
|
||||||
try:
|
try:
|
||||||
cmd = "third_party/wrk/%s/wrk -d %s http://%s/" % (util.platform(),
|
cmd = "third_party/wrk/%s/wrk -d %s http://%s/" % (util.platform(),
|
||||||
|
@ -64,4 +86,4 @@ if __name__ == '__main__':
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
print "Usage ./tools/http_benchmark.py target/debug/deno"
|
print "Usage ./tools/http_benchmark.py target/debug/deno"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
deno_http_benchmark(sys.argv[1])
|
deno_net_http_benchmark(sys.argv[1])
|
||||||
|
|
Loading…
Reference in a new issue