Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
f20b05af
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,发现更多精彩内容 >>
未验证
提交
f20b05af
编写于
4月 17, 2019
作者:
R
Ryan Dahl
提交者:
GitHub
4月 17, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
benchmarks: fix max_memory and clean up (#2137)
上级
8477daa8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
71 addition
and
58 deletion
+71
-58
tools/benchmark.py
tools/benchmark.py
+67
-54
tools/http_benchmark.py
tools/http_benchmark.py
+4
-4
未找到文件。
tools/benchmark.py
浏览文件 @
f20b05af
...
...
@@ -125,13 +125,13 @@ def get_strace_summary(test_args):
return
strace_parse
(
get_strace_summary_text
(
test_args
))
def
run_thread_count_benchmark
(
deno_
path
):
def
run_thread_count_benchmark
(
deno_
exe
):
thread_count_map
=
{}
thread_count_map
[
"set_timeout"
]
=
get_strace_summary
([
deno_
path
,
"--reload"
,
"tests/004_set_timeout.ts"
deno_
exe
,
"--reload"
,
"tests/004_set_timeout.ts"
])[
"clone"
][
"calls"
]
+
1
thread_count_map
[
"fetch_deps"
]
=
get_strace_summary
([
deno_
path
,
"--reload"
,
"--allow-net"
,
"tests/fetch_deps.ts"
deno_
exe
,
"--reload"
,
"--allow-net"
,
"tests/fetch_deps.ts"
])[
"clone"
][
"calls"
]
+
1
return
thread_count_map
...
...
@@ -145,12 +145,12 @@ def run_throughput(deno_exe):
return
m
def
run_syscall_count_benchmark
(
deno_
path
):
def
run_syscall_count_benchmark
(
deno_
exe
):
syscall_count_map
=
{}
syscall_count_map
[
"hello"
]
=
get_strace_summary
(
[
deno_
path
,
"--reload"
,
"tests/002_hello.ts"
])[
"total"
][
"calls"
]
[
deno_
exe
,
"--reload"
,
"tests/002_hello.ts"
])[
"total"
][
"calls"
]
syscall_count_map
[
"fetch_deps"
]
=
get_strace_summary
(
[
deno_
path
,
"--reload"
,
"--allow-net"
,
[
deno_
exe
,
"--reload"
,
"--allow-net"
,
"tests/fetch_deps.ts"
])[
"total"
][
"calls"
]
return
syscall_count_map
...
...
@@ -164,10 +164,47 @@ def find_max_mem_in_bytes(time_v_output):
return
int
(
value
)
*
1024
def
run_max_mem_benchmark
(
deno_path
):
cmd
=
[
"/usr/bin/time"
,
"-v"
,
deno_path
,
"--reload"
,
"tests/002_hello.ts"
]
out
=
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
)
return
find_max_mem_in_bytes
(
out
)
def
run_max_mem_benchmark
(
deno_exe
):
results
=
{}
for
(
name
,
args
)
in
exec_time_benchmarks
:
cmd
=
[
"/usr/bin/time"
,
"-v"
,
deno_exe
]
+
args
try
:
out
=
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
)
except
subprocess
.
CalledProcessError
:
pass
mem
=
find_max_mem_in_bytes
(
out
)
results
[
name
]
=
mem
return
results
def
run_exec_time
(
deno_exe
,
build_dir
):
benchmark_file
=
os
.
path
.
join
(
build_dir
,
"hyperfine_results.json"
)
hyperfine
=
prebuilt
.
load_hyperfine
()
run
([
hyperfine
,
"--ignore-failure"
,
"--export-json"
,
benchmark_file
,
"--warmup"
,
"3"
]
+
[
deno_exe
+
" "
+
" "
.
join
(
args
)
for
[
_
,
args
]
in
exec_time_benchmarks
])
hyperfine_results
=
read_json
(
benchmark_file
)
results
=
{}
for
[[
name
,
_
],
data
]
in
zip
(
exec_time_benchmarks
,
hyperfine_results
[
"results"
]):
results
[
name
]
=
{
"mean"
:
data
[
"mean"
],
"stddev"
:
data
[
"stddev"
],
"user"
:
data
[
"user"
],
"system"
:
data
[
"system"
],
"min"
:
data
[
"min"
],
"max"
:
data
[
"max"
]
}
return
results
def
run_http
(
build_dir
,
new_data
):
stats
=
http_benchmark
(
build_dir
)
new_data
[
"req_per_sec"
]
=
{
k
:
v
[
"req_per_sec"
]
for
k
,
v
in
stats
.
items
()}
new_data
[
"max_latency"
]
=
{
k
:
v
[
"max_latency"
]
for
k
,
v
in
stats
.
items
()}
def
main
(
argv
):
...
...
@@ -179,68 +216,44 @@ def main(argv):
print
"Usage: tools/benchmark.py [build_dir]"
sys
.
exit
(
1
)
sha1
=
run_output
([
"git"
,
"rev-parse"
,
"HEAD"
]).
strip
()
http_server
.
spawn
()
deno_path
=
os
.
path
.
join
(
build_dir
,
"deno"
)
benchmark_file
=
os
.
path
.
join
(
build_dir
,
"benchmark.json"
)
deno_exe
=
os
.
path
.
join
(
build_dir
,
"deno"
)
os
.
chdir
(
root_path
)
import_data_from_gh_pages
()
hyperfine
=
prebuilt
.
load_hyperfine
()
run
([
hyperfine
,
"--ignore-failure"
,
"--export-json"
,
benchmark_file
,
"--warmup"
,
"3"
]
+
[
deno_path
+
" "
+
" "
.
join
(
args
)
for
[
_
,
args
]
in
exec_time_benchmarks
])
all_data
=
read_json
(
all_data_file
)
benchmark_data
=
read_json
(
benchmark_file
)
sha1
=
run_output
([
"git"
,
"rev-parse"
,
"HEAD"
]).
strip
()
new_data
=
{
"created_at"
:
time
.
strftime
(
"%Y-%m-%dT%H:%M:%SZ"
),
"sha1"
:
sha1
,
"binary_size"
:
{},
"thread_count"
:
{},
"syscall_count"
:
{},
"benchmark"
:
{}
}
for
[[
name
,
_
],
data
]
in
zip
(
exec_time_benchmarks
,
benchmark_data
[
"results"
]):
new_data
[
"benchmark"
][
name
]
=
{
"mean"
:
data
[
"mean"
],
"stddev"
:
data
[
"stddev"
],
"user"
:
data
[
"user"
],
"system"
:
data
[
"system"
],
"min"
:
data
[
"min"
],
"max"
:
data
[
"max"
]
}
# TODO(ry) The "benchmark" benchmark should actually be called "exec_time".
# When this is changed, the historical data in gh-pages branch needs to be
# changed too.
new_data
[
"benchmark"
]
=
run_exec_time
(
deno_exe
,
build_dir
)
new_data
[
"binary_size"
]
=
get_binary_sizes
(
build_dir
)
# Cannot run throughput benchmark on windows because they don't have nc or
# pipe.
if
os
.
name
!=
'nt'
:
hyper_hello_path
=
os
.
path
.
join
(
build_dir
,
"hyper_hello"
)
core_http_bench_exe
=
os
.
path
.
join
(
build_dir
,
"deno_core_http_bench"
)
new_data
[
"throughput"
]
=
run_throughput
(
deno_path
)
stats
=
http_benchmark
(
deno_path
,
hyper_hello_path
,
core_http_bench_exe
)
new_data
[
"req_per_sec"
]
=
{
k
:
v
[
"req_per_sec"
]
for
k
,
v
in
stats
.
items
()
}
new_data
[
"max_latency"
]
=
{
k
:
v
[
"max_latency"
]
for
k
,
v
in
stats
.
items
()
}
new_data
[
"throughput"
]
=
run_throughput
(
deno_exe
)
run_http
(
build_dir
,
new_data
)
if
"linux"
in
sys
.
platform
:
# Thread count test, only on linux
new_data
[
"thread_count"
]
=
run_thread_count_benchmark
(
deno_path
)
new_data
[
"syscall_count"
]
=
run_syscall_count_benchmark
(
deno_path
)
new_data
[
"max_memory"
]
=
run_max_mem_benchmark
(
deno_path
)
new_data
[
"thread_count"
]
=
run_thread_count_benchmark
(
deno_exe
)
new_data
[
"syscall_count"
]
=
run_syscall_count_benchmark
(
deno_exe
)
new_data
[
"max_memory"
]
=
run_max_mem_benchmark
(
deno_exe
)
print
"===== <BENCHMARK RESULTS>"
print
json
.
dumps
(
new_data
,
indent
=
2
)
print
"===== </BENCHMARK RESULTS>"
all_data
=
read_json
(
all_data_file
)
all_data
.
append
(
new_data
)
write_json
(
all_data_file
,
all_data
)
write_json
(
recent_data_file
,
all_data
[
-
20
:])
...
...
tools/http_benchmark.py
浏览文件 @
f20b05af
...
...
@@ -58,10 +58,10 @@ def hyper_http_benchmark(hyper_hello_exe):
return
run
(
hyper_cmd
)
def
http_benchmark
(
deno_exe
,
hyper_hello_exe
,
core_http_bench_exe
):
# TODO Rename to "deno_tcp"
def
http_benchmark
(
build_dir
):
hyper_hello_exe
=
os
.
path
.
join
(
build_dir
,
"hyper_hello"
)
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
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录