Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
4ea2df67
D
deno
项目概览
张重言
/
deno
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
deno
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
4ea2df67
编写于
6月 07, 2019
作者:
K
Kurt Mackey
提交者:
Ryan Dahl
6月 07, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
http benchmarks with unique ports (#2471)
上级
9a6cfd65
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
62 addition
and
33 deletion
+62
-33
tools/deno_http_proxy.ts
tools/deno_http_proxy.ts
+1
-1
tools/deno_tcp_proxy.ts
tools/deno_tcp_proxy.ts
+1
-1
tools/http_benchmark.py
tools/http_benchmark.py
+60
-31
未找到文件。
tools/deno_http_proxy.ts
浏览文件 @
4ea2df67
...
...
@@ -9,7 +9,7 @@ const originAddr = Deno.args[2] || "127.0.0.1:4501";
const
server
=
serve
(
addr
);
async
function
main
():
Promise
<
void
>
{
console
.
log
(
`http://
${
addr
}
/`
);
console
.
log
(
`
Proxy listening on
http://
${
addr
}
/`
);
for
await
(
const
req
of
server
)
{
proxyRequest
(
req
);
}
...
...
tools/deno_tcp_proxy.ts
浏览文件 @
4ea2df67
...
...
@@ -19,7 +19,7 @@ async function handle(conn: Deno.Conn): Promise<void> {
}
async
function
main
():
Promise
<
void
>
{
console
.
log
(
"
Listening on
"
,
addr
);
console
.
log
(
`Proxy listening on http://
${
addr
}
/`
);
while
(
true
)
{
const
conn
=
await
listener
.
accept
();
handle
(
conn
);
...
...
tools/http_benchmark.py
浏览文件 @
4ea2df67
...
...
@@ -12,25 +12,36 @@ import subprocess
# "deno_tcp" was once called "deno"
# "deno_http" was once called "deno_net_http"
ADDR
=
"127.0.0.1:4544"
ORIGIN_ADDR
=
"127.0.0.1:4545"
DURATION
=
"10s"
LAST_PORT
=
4544
def
get_addr
(
port
=
None
):
global
LAST_PORT
if
port
is
None
:
port
=
LAST_PORT
LAST_PORT
=
LAST_PORT
+
1
return
(
"127.0.0.1:%d"
%
(
port
))
def
deno_tcp
(
deno_exe
):
deno_cmd
=
[
deno_exe
,
"run"
,
"--allow-net"
,
"tools/deno_tcp.ts"
,
ADDR
]
addr
=
get_addr
()
deno_cmd
=
[
deno_exe
,
"run"
,
"--allow-net"
,
"tools/deno_tcp.ts"
,
addr
]
print
"http_benchmark testing DENO."
return
run
(
deno_cmd
)
return
run
(
deno_cmd
,
addr
)
def
deno_http
(
deno_exe
):
addr
=
get_addr
()
deno_cmd
=
[
deno_exe
,
"run"
,
"--allow-net"
,
"js/deps/https/deno.land/std/http/http_bench.ts"
,
ADDR
"js/deps/https/deno.land/std/http/http_bench.ts"
,
addr
]
print
"http_benchmark testing DENO using net/http."
return
run
(
deno_cmd
,
addr
,
merge_env
=
{
# Load from //js/deps/https/deno.land/net/ submodule.
"DENO_DIR"
:
os
.
path
.
join
(
util
.
root_path
,
"js"
)
...
...
@@ -38,75 +49,94 @@ def deno_http(deno_exe):
def
deno_tcp_proxy
(
deno_exe
,
hyper_hello_exe
):
addr
=
get_addr
()
origin_addr
=
get_addr
()
deno_cmd
=
[
deno_exe
,
"run"
,
"--allow-net"
,
"tools/deno_tcp_proxy.ts"
,
ADDR
,
ORIGIN_ADDR
deno_exe
,
"run"
,
"--allow-net"
,
"tools/deno_tcp_proxy.ts"
,
addr
,
origin_addr
]
print
"http_proxy_benchmark testing DENO using net/tcp."
return
run
(
deno_cmd
,
addr
,
merge_env
=
{
"DENO_DIR"
:
os
.
path
.
join
(
util
.
root_path
,
"js"
)},
origin_cmd
=
http_proxy_origin
(
hyper_hello_exe
))
origin_cmd
=
http_proxy_origin
(
hyper_hello_exe
,
origin_addr
))
def
deno_http_proxy
(
deno_exe
,
hyper_hello_exe
):
addr
=
get_addr
()
origin_addr
=
get_addr
()
deno_cmd
=
[
deno_exe
,
"run"
,
"--allow-net"
,
"tools/deno_http_proxy.ts"
,
ADDR
,
ORIGIN_ADDR
deno_exe
,
"run"
,
"--allow-net"
,
"tools/deno_http_proxy.ts"
,
addr
,
origin_addr
]
print
"http_proxy_benchmark testing DENO using net/http."
return
run
(
deno_cmd
,
addr
,
merge_env
=
{
"DENO_DIR"
:
os
.
path
.
join
(
util
.
root_path
,
"js"
)},
origin_cmd
=
http_proxy_origin
(
hyper_hello_exe
))
origin_cmd
=
http_proxy_origin
(
hyper_hello_exe
,
origin_addr
))
def
deno_core_single
(
exe
):
print
"http_benchmark testing deno_core_single"
return
run
([
exe
,
"--single-thread"
])
return
run
([
exe
,
"--single-thread"
]
,
"127.0.0.1:4544"
)
def
deno_core_multi
(
exe
):
print
"http_benchmark testing deno_core_multi"
return
run
([
exe
,
"--multi-thread"
])
return
run
([
exe
,
"--multi-thread"
]
,
"127.0.0.1:4544"
)
def
node_http
():
node_cmd
=
[
"node"
,
"tools/node_http.js"
,
ADDR
.
split
(
":"
)[
1
]]
addr
=
get_addr
()
node_cmd
=
[
"node"
,
"tools/node_http.js"
,
addr
.
split
(
":"
)[
1
]]
print
"http_benchmark testing NODE."
return
run
(
node_cmd
)
return
run
(
node_cmd
,
addr
)
def
node_http_proxy
(
hyper_hello_exe
):
node_cmd
=
[
"node"
,
"tools/node_http_proxy.js"
,
ADDR
.
split
(
":"
)[
1
]]
addr
=
get_addr
()
origin_addr
=
get_addr
()
node_cmd
=
[
"node"
,
"tools/node_http_proxy.js"
,
addr
.
split
(
":"
)[
1
],
origin_addr
.
split
(
":"
)[
1
]
]
print
"http_proxy_benchmark testing NODE."
return
run
(
node_cmd
,
None
,
http_proxy_origin
(
hyper_hello_exe
))
return
run
(
node_cmd
,
addr
,
None
,
http_proxy_origin
(
hyper_hello_exe
,
origin_addr
))
def
node_tcp_proxy
(
hyper_hello_exe
):
addr
=
get_addr
()
origin_addr
=
get_addr
()
node_cmd
=
[
"node"
,
"tools/node_tcp_proxy.js"
,
ADDR
.
split
(
":"
)[
1
],
ORIGIN_ADDR
.
split
(
":"
)[
1
]
addr
.
split
(
":"
)[
1
],
origin_addr
.
split
(
":"
)[
1
]
]
print
"http_proxy_benchmark testing NODE tcp."
return
run
(
node_cmd
,
None
,
http_proxy_origin
(
hyper_hello_exe
))
return
run
(
node_cmd
,
addr
,
None
,
http_proxy_origin
(
hyper_hello_exe
,
origin_addr
))
def
node_tcp
():
node_cmd
=
[
"node"
,
"tools/node_tcp.js"
,
ADDR
.
split
(
":"
)[
1
]]
addr
=
get_addr
()
node_cmd
=
[
"node"
,
"tools/node_tcp.js"
,
addr
.
split
(
":"
)[
1
]]
print
"http_benchmark testing node_tcp.js"
return
run
(
node_cmd
)
return
run
(
node_cmd
,
addr
)
def
http_proxy_origin
(
hyper_hello_exe
):
return
[
hyper_hello_exe
,
ORIGIN_ADDR
.
split
(
":"
)[
1
]]
def
http_proxy_origin
(
hyper_hello_exe
,
addr
):
return
[
hyper_hello_exe
,
addr
.
split
(
":"
)[
1
]]
def
hyper_http
(
hyper_hello_exe
):
hyper_cmd
=
[
hyper_hello_exe
,
ADDR
.
split
(
":"
)[
1
]]
addr
=
get_addr
()
hyper_cmd
=
[
hyper_hello_exe
,
addr
.
split
(
":"
)[
1
]]
print
"http_benchmark testing RUST hyper."
return
run
(
hyper_cmd
)
return
run
(
hyper_cmd
,
addr
)
def
http_benchmark
(
build_dir
):
...
...
@@ -131,7 +161,8 @@ def http_benchmark(build_dir):
}
def
run
(
server_cmd
,
merge_env
=
None
,
origin_cmd
=
None
):
def
run
(
server_cmd
,
addr
,
merge_env
=
None
,
origin_cmd
=
None
):
# Run deno echo server in the background.
if
merge_env
is
None
:
env
=
None
...
...
@@ -146,16 +177,15 @@ def run(server_cmd, merge_env=None, origin_cmd=None):
origin
=
None
if
origin_cmd
is
not
None
:
print
"Starting origin server"
origin
=
subprocess
.
Popen
(
origin_cmd
,
env
=
env
)
server
=
subprocess
.
Popen
(
server_cmd
,
env
=
env
)
time
.
sleep
(
1
5
)
# wait for server to wake up. TODO racy.
time
.
sleep
(
1
0
)
# wait for server to wake up. TODO racy.
try
:
cmd
=
"third_party/wrk/%s/wrk -d %s http://%s/"
%
(
util
.
platform
(),
DURATION
,
ADDR
)
DURATION
,
addr
)
print
cmd
output
=
subprocess
.
check_output
(
cmd
,
shell
=
True
)
stats
=
util
.
parse_wrk_output
(
output
)
...
...
@@ -164,7 +194,6 @@ def run(server_cmd, merge_env=None, origin_cmd=None):
finally
:
server
.
kill
()
if
origin
is
not
None
:
print
"Stopping origin server"
origin
.
kill
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录