Skip to content

Commit

Permalink
undo berts non-fix changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jul 4, 2020
1 parent 08d4175 commit 47bf17c
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 48 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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[0] || "0.0.0.0:4544";
const addr = Deno.args[1] || "0.0.0.0:4544";
const [hostname, port] = addr.split(":");
const listener = Deno.listen({ hostname, port: Number(port) });
console.log("listening on", addr);
Expand Down
62 changes: 38 additions & 24 deletions tools/http_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,55 @@

DURATION = "20s"

LAST_PORT = 4544


def server_addr(port):
return "0.0.0.0:%s" % port


def get_port(port=None):
global LAST_PORT
if port is None:
port = LAST_PORT
LAST_PORT = LAST_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 = util.get_port()
port = get_port()
deno_cmd = [
# TODO(lucacasonato): remove unstable when stabilized
deno_exe,
"run",
"--allow-net",
"tools/deno_tcp.ts",
util.server_addr(port)
server_addr(port)
]
print "http_benchmark testing DENO tcp."
return run(deno_cmd, port)


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


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


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


def hyper_http(hyper_hello_exe):
port = util.get_port()
port = get_port()
hyper_cmd = [hyper_hello_exe, port]
print "http_benchmark testing RUST hyper."
return run(hyper_cmd, port)
Expand Down Expand Up @@ -177,14 +193,12 @@ def run(server_cmd, port, merge_env=None, origin_cmd=None):
return stats
finally:
server_retcode = server.poll()
server.kill()
server.wait()
if origin is not None:
origin.kill()
origin.wait()
if server_retcode is not None and server_retcode != 0:
print "server ended with error"
sys.exit(1)
server.kill()
if origin is not None:
origin.kill()


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion tools/hyper_hello/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2018"

[dependencies]
hyper = "0.13.6"
tokio = { version = "0.2.21", features = ["rt-core", "tcp", "udp", "uds", "process", "fs", "blocking", "sync", "io-std", "macros", "time"] }
tokio = { version = "0.2.21", features = ["full"] }

[[bin]]
name = "hyper_hello"
Expand Down
10 changes: 4 additions & 6 deletions tools/throughput_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import util

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


def cat(deno_exe, megs):
Expand All @@ -29,27 +30,24 @@ 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 %s %s" % (CLIENT_ADDR, port)
nc_cmd = "nc " + CLIENT_ADDR
cmd = ("head -c %s /dev/zero " % size) + " | " + nc_cmd
print cmd
subprocess.check_output(cmd, shell=True)
end = time.time()
return end - start
finally:
echo_server.kill()
echo_server.wait()


def main():
Expand Down
16 changes: 0 additions & 16 deletions tools/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,19 +428,3 @@ 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 47bf17c

Please sign in to comment.