Skip to content

Commit

Permalink
Ok getting more invasive now
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed Jul 4, 2020
1 parent 1a49224 commit 0b1649c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 38 deletions.
2 changes: 1 addition & 1 deletion cli/tests/echo_server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const addr = Deno.args[1] || "0.0.0.0:4544";
const addr = Deno.args[0] || "0.0.0.0:4500";
const [hostname, port] = addr.split(":");
const listener = Deno.listen({ hostname, port: Number(port) });
console.log("listening on", addr);
Expand Down
52 changes: 19 additions & 33 deletions tools/http_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,54 +14,40 @@
# "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()
port = util.get_port()
deno_cmd = [
# TODO(lucacasonato): remove unstable when stabilized
deno_exe,
"run",
"--allow-net",
"tools/deno_tcp.ts",
server_addr(port)
util.server_addr(port)
]
print "http_benchmark testing DENO tcp."
return run(deno_cmd, port)


def deno_http(deno_exe):
port = get_port()
port = util.get_port()
deno_cmd = [
deno_exe, "run", "--allow-net", "--reload", "--unstable",
"std/http/http_bench.ts",
server_addr(port)
util.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()
port = util.get_port()
origin_port = util.get_port()
deno_cmd = [
deno_exe, "run", "--allow-net", "tools/deno_tcp_proxy.ts",
server_addr(port),
server_addr(origin_port)
util.server_addr(port),
util.server_addr(origin_port)
]
print "http_proxy_benchmark testing DENO using net/tcp."
return run(
Expand All @@ -71,12 +57,12 @@ def deno_tcp_proxy(deno_exe, hyper_hello_exe):


def deno_http_proxy(deno_exe, hyper_hello_exe):
port = get_port()
origin_port = get_port()
port = util.get_port()
origin_port = util.get_port()
deno_cmd = [
deno_exe, "run", "--allow-net", "tools/deno_http_proxy.ts",
server_addr(port),
server_addr(origin_port)
util.server_addr(port),
util.server_addr(origin_port)
]
print "http_proxy_benchmark testing DENO using net/http."
return run(
Expand All @@ -91,32 +77,32 @@ def deno_core_http_bench(exe):


def node_http():
port = get_port()
port = util.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()
port = util.get_port()
origin_port = util.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()
port = util.get_port()
origin_port = util.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()
port = util.get_port()
node_cmd = ["node", "tools/node_tcp.js", port]
print "http_benchmark testing node_tcp.js"
return run(node_cmd, port)
Expand All @@ -127,7 +113,7 @@ def http_proxy_origin(hyper_hello_exe, port):


def hyper_http(hyper_hello_exe):
port = get_port()
port = util.get_port()
hyper_cmd = [hyper_hello_exe, port]
print "http_benchmark testing RUST hyper."
return run(hyper_cmd, port)
Expand Down
9 changes: 5 additions & 4 deletions tools/throughput_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
import util

MB = 1024 * 1024
SERVER_ADDR = "0.0.0.0:4544"
CLIENT_ADDR = "127.0.0.1 4544"
CLIENT_ADDR = "127.0.0.1"


def cat(deno_exe, megs):
Expand All @@ -30,17 +29,19 @@ def cat(deno_exe, megs):

def tcp(deno_exe, megs):
size = megs * MB
port = util.get_port()
server_addr = util.server_addr(port)
# Run deno echo server in the background.
args = [
deno_exe, "run", "--allow-net", "cli/tests/echo_server.ts", SERVER_ADDR
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 -N " + CLIENT_ADDR
nc_cmd = "nc %s %s" % (CLIENT_ADDR, port)
cmd = ("head -c %s /dev/zero " % size) + " | " + nc_cmd
print cmd
subprocess.check_output(cmd, shell=True)
Expand Down
16 changes: 16 additions & 0 deletions tools/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,19 @@ def tty_capture(cmd, bytes_input, timeout=5):
def print_command(cmd, files):
noun = "file" if len(files) == 1 else "files"
print "%s (%d %s)" % (cmd, len(files), noun)


NEXT_PORT = 4544


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 server_addr(port):
return "0.0.0.0:%s" % port

0 comments on commit 0b1649c

Please sign in to comment.