Skip to content

Commit

Permalink
Rename HTTP benchmarks (denoland#2350)
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed May 14, 2019
1 parent 5e56e26 commit 160a815
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 26 deletions.
File renamed without changes.
33 changes: 21 additions & 12 deletions tools/http_benchmark.py
Expand Up @@ -6,17 +6,23 @@
import time
import subprocess

# 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"

ADDR = "127.0.0.1:4544"
DURATION = "10s"


def deno_http_benchmark(deno_exe):
deno_cmd = [deno_exe, "run", "--allow-net", "tests/http_bench.ts", ADDR]
def deno_tcp(deno_exe):
deno_cmd = [deno_exe, "run", "--allow-net", "tools/deno_tcp.ts", ADDR]
print "http_benchmark testing DENO."
return run(deno_cmd)


def deno_net_http_benchmark(deno_exe):
def deno_http(deno_exe):
deno_cmd = [
deno_exe, "run", "--allow-net",
"js/deps/https/deno.land/std/http/http_bench.ts", ADDR
Expand All @@ -40,19 +46,19 @@ def deno_core_multi(exe):
return run([exe, "--multi-thread"])


def node_http_benchmark():
def node_http():
node_cmd = ["node", "tools/node_http.js", ADDR.split(":")[1]]
print "http_benchmark testing NODE."
return run(node_cmd)


def node_tcp_benchmark():
def node_tcp():
node_cmd = ["node", "tools/node_tcp.js", ADDR.split(":")[1]]
print "http_benchmark testing node_tcp.js"
return run(node_cmd)


def hyper_http_benchmark(hyper_hello_exe):
def hyper_http(hyper_hello_exe):
hyper_cmd = [hyper_hello_exe, ADDR.split(":")[1]]
print "http_benchmark testing RUST hyper."
return run(hyper_cmd)
Expand All @@ -63,13 +69,16 @@ def http_benchmark(build_dir):
core_http_bench_exe = os.path.join(build_dir, "deno_core_http_bench")
deno_exe = os.path.join(build_dir, "deno")
return {
"deno": deno_http_benchmark(deno_exe),
"deno_net_http": deno_net_http_benchmark(deno_exe),
# "deno_tcp" was once called "deno"
"deno_tcp": deno_tcp(deno_exe),
# "deno_http" was once called "deno_net_http"
"deno_http": deno_http(deno_exe),
"deno_core_single": deno_core_single(core_http_bench_exe),
"deno_core_multi": deno_core_multi(core_http_bench_exe),
"node": node_http_benchmark(),
"node_tcp": node_tcp_benchmark(),
"hyper": hyper_http_benchmark(hyper_hello_exe)
# "node_http" was once called "node"
"node_http": node_http(),
"node_tcp": node_tcp(),
"hyper": hyper_http(hyper_hello_exe)
}


Expand Down Expand Up @@ -106,4 +115,4 @@ def run(server_cmd, merge_env=None):
if len(sys.argv) < 2:
print "Usage ./tools/http_benchmark.py target/debug/deno"
sys.exit(1)
deno_net_http_benchmark(sys.argv[1])
deno_http(sys.argv[1])
37 changes: 23 additions & 14 deletions website/benchmarks.html
Expand Up @@ -34,37 +34,46 @@ <h3 id="req-per-sec">Req/Sec <a href="#req-per-sec">#</a></h3>
</p>

<ul>
<!-- TODO rename "deno" to "deno_tcp". -->
<li>
<a
href="https://github.com/denoland/deno/blob/master/tests/http_bench.ts"
>
deno
</a>
href="https://github.com/denoland/deno/blob/master/tools/deno_tcp.ts"
>deno_tcp</a>
is a fake http server that doesn't parse HTTP. It is comparable to
<a
href="https://github.com/denoland/deno/blob/master/tools/node_tcp.js"
>
node_tcp
</a>
>node_tcp</a>
.
</li>

<li>
<a
href="https://github.com/denoland/deno_std/blob/master/http/http_bench.ts"
>
deno_net_http
</a>
>deno_http</a>
is a web server written in TypeScript. It is comparable to
<a
href="https://github.com/denoland/deno/blob/master/tools/node_http.js"
>
node_http
</a>
>node_http</a>
.
</li>

<li>deno_core_single and deno_core_multi are two versions of
a minimal fake HTTP server. It blindly reads and writes fixed HTTP
packets. It is comparable to deno_tcp and node_tcp.
This is a standalone executable that uses <a
href="https://crates.io/crates/deno">the deno rust crate</a>. The
code is in
<a
href="https://github.com/denoland/deno/blob/master/core/examples/http_bench.rs"
>http_bench.rs</a>
and
<a
href="https://github.com/denoland/deno/blob/master/core/examples/http_bench.js"
>http_bench.js</a>. single uses <a
href="https://docs.rs/tokio/0.1.19/tokio/runtime/current_thread/index.html">tokio::runtime::current_thread</a>
and multi uses <a
href="https://docs.rs/tokio/0.1.19/tokio/runtime/">tokio::runtime::threadpool</a>.
</li>

<li>
<a
href="https://github.com/denoland/deno/blob/master/tools/hyper_hello.rs"
Expand Down

0 comments on commit 160a815

Please sign in to comment.