Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
4da842a9
S
Serving
项目概览
PaddlePaddle
/
Serving
10 个月 前同步成功
通知
183
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
4da842a9
编写于
3月 12, 2021
作者:
R
root
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add to benchmark
上级
304b4e05
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
83 addition
and
1 deletion
+83
-1
python/examples/pipeline/simple_web_service/benchmark.py
python/examples/pipeline/simple_web_service/benchmark.py
+65
-0
python/examples/pipeline/simple_web_service/benchmark.sh
python/examples/pipeline/simple_web_service/benchmark.sh
+17
-0
python/examples/pipeline/simple_web_service/web_service.py
python/examples/pipeline/simple_web_service/web_service.py
+1
-1
未找到文件。
python/examples/pipeline/simple_web_service/benchmark.py
0 → 100644
浏览文件 @
4da842a9
import
sys
import
os
import
yaml
import
requests
import
time
import
json
try
:
from
paddle_serving_server_gpu.pipeline
import
PipelineClient
except
ImportError
:
from
paddle_serving_server.pipeline
import
PipelineClient
import
numpy
as
np
from
paddle_serving_client.utils
import
MultiThreadRunner
from
paddle_serving_client.utils
import
benchmark_args
,
show_latency
def
gen_yml
():
fin
=
open
(
"config.yml"
,
"r"
)
config
=
yaml
.
load
(
fin
)
fin
.
close
()
config
[
"dag"
][
"tracer"
]
=
{
"interval_s"
:
5
}
with
open
(
"config2.yml"
,
"w"
)
as
fout
:
yaml
.
dump
(
config
,
fout
,
default_flow_style
=
False
)
def
run_http
(
idx
,
batch_size
):
print
(
"start thread ({})"
.
format
(
idx
))
url
=
"http://127.0.0.1:18082/uci/prediction"
start
=
time
.
time
()
data
=
{
"key"
:
[
"x"
],
"value"
:
[
"0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332"
]}
for
i
in
range
(
1000
):
r
=
requests
.
post
(
url
=
url
,
data
=
json
.
dumps
(
data
))
print
(
r
.
json
())
end
=
time
.
time
()
return
[[
end
-
start
]]
def
multithread_http
(
thread
,
batch_size
):
multi_thread_runner
=
MultiThreadRunner
()
result
=
multi_thread_runner
.
run
(
run_http
,
thread
,
batch_size
)
def
multithread_rpc
(
thraed
,
batch_size
):
multi_thread_runner
=
MultiThreadRunner
()
def
run_rpc
(
thread
,
batch_size
):
client
=
PipelineClient
()
client
.
connect
([
'127.0.0.1:9998'
])
data
=
{
"key"
:
"x"
,
"value"
:
"0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332"
}
ret
=
client
.
predict
(
feed_dict
=
{
data
[
"key"
]:
data
[
"value"
]},
fetch
=
[
"res"
])
print
(
ret
)
if
__name__
==
"__main__"
:
if
sys
.
argv
[
1
]
==
"yaml"
:
mode
=
sys
.
argv
[
2
]
# brpc/ local predictor
thread
=
int
(
sys
.
argv
[
3
])
gen_yml
()
elif
sys
.
argv
[
1
]
==
"run"
:
mode
=
sys
.
argv
[
2
]
# http/ rpc
thread
=
int
(
sys
.
argv
[
3
])
batch_size
=
int
(
sys
.
argv
[
4
])
if
mode
==
"http"
:
multithread_http
(
thread
,
batch_size
)
elif
mode
==
"rpc"
:
run_rpc
(
thread
,
batch_size
)
python/examples/pipeline/simple_web_service/benchmark.sh
0 → 100644
浏览文件 @
4da842a9
ps
-ef
|
grep
web_service |
awk
'{print $2}'
| xargs
kill
-9
rm
-rf
PipelineServingLogs
rm
-rf
cpu_utilization.py
sleep
3
python3 benchmark.py yaml local_predictor 1
for
thread_num
in
1 8 32
do
python3 web_service.py
>
web.log 2>&1 &
sleep
3
echo
"import psutil
\n
cpu_utilization=psutil.cpu_percent(1,False)
\n
print('CPU_UTILIZATION:', cpu_utilization)
\n
"
>
cpu_utilization.py
python3 benchmark.py run http
$thread_num
1
python3 cpu_utilization.py
echo
"------------Fit a line pipeline benchmark (Thread:
$thread_num
) (Benchmark: 1)"
tail
-n
25 PipelineServingLogs/pipeline.tracer
ps
-ef
|
grep
web_service |
awk
'{print $2}'
| xargs
kill
-9
done
python/examples/pipeline/simple_web_service/web_service.py
浏览文件 @
4da842a9
...
...
@@ -61,5 +61,5 @@ class UciService(WebService):
uci_service
=
UciService
(
name
=
"uci"
)
uci_service
.
prepare_pipeline_config
(
"config.yml"
)
uci_service
.
prepare_pipeline_config
(
"config
2
.yml"
)
uci_service
.
run_service
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录