Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
c107c3c4
S
Serving
项目概览
PaddlePaddle
/
Serving
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
c107c3c4
编写于
6月 09, 2020
作者:
M
MRXLT
提交者:
GitHub
6月 09, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into 0.3.0-bug-fix
上级
94eb1be9
d49dbc6d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
13 deletion
+37
-13
python/examples/bert/benchmark.py
python/examples/bert/benchmark.py
+36
-4
python/examples/bert/bert_client.py
python/examples/bert/bert_client.py
+0
-8
python/examples/imagenet/benchmark.py
python/examples/imagenet/benchmark.py
+1
-1
未找到文件。
python/examples/bert/benchmark.py
浏览文件 @
c107c3c4
...
@@ -19,6 +19,8 @@ from __future__ import unicode_literals, absolute_import
...
@@ -19,6 +19,8 @@ from __future__ import unicode_literals, absolute_import
import
os
import
os
import
sys
import
sys
import
time
import
time
import
json
import
requests
from
paddle_serving_client
import
Client
from
paddle_serving_client
import
Client
from
paddle_serving_client.utils
import
MultiThreadRunner
from
paddle_serving_client.utils
import
MultiThreadRunner
from
paddle_serving_client.utils
import
benchmark_args
,
show_latency
from
paddle_serving_client.utils
import
benchmark_args
,
show_latency
...
@@ -72,7 +74,39 @@ def single_func(idx, resource):
...
@@ -72,7 +74,39 @@ def single_func(idx, resource):
print
(
"unsupport batch size {}"
.
format
(
args
.
batch_size
))
print
(
"unsupport batch size {}"
.
format
(
args
.
batch_size
))
elif
args
.
request
==
"http"
:
elif
args
.
request
==
"http"
:
raise
(
"not implemented"
)
reader
=
ChineseBertReader
({
"max_seq_len"
:
128
})
fetch
=
[
"pooled_output"
]
server
=
"http://"
+
resource
[
"endpoint"
][
idx
%
len
(
resource
[
"endpoint"
])]
+
"/bert/prediction"
start
=
time
.
time
()
for
i
in
range
(
turns
):
if
args
.
batch_size
>=
1
:
l_start
=
time
.
time
()
feed_batch
=
[]
b_start
=
time
.
time
()
for
bi
in
range
(
args
.
batch_size
):
feed_batch
.
append
({
"words"
:
dataset
[
bi
]})
req
=
json
.
dumps
({
"feed"
:
feed_batch
,
"fetch"
:
fetch
})
b_end
=
time
.
time
()
if
profile_flags
:
sys
.
stderr
.
write
(
"PROFILE
\t
pid:{}
\t
bert_pre_0:{} bert_pre_1:{}
\n
"
.
format
(
os
.
getpid
(),
int
(
round
(
b_start
*
1000000
)),
int
(
round
(
b_end
*
1000000
))))
result
=
requests
.
post
(
server
,
data
=
req
,
headers
=
{
"Content-Type"
:
"application/json"
})
l_end
=
time
.
time
()
if
latency_flags
:
latency_list
.
append
(
l_end
*
1000
-
l_start
*
1000
)
else
:
print
(
"unsupport batch size {}"
.
format
(
args
.
batch_size
))
else
:
raise
ValueError
(
"not implemented {} request"
.
format
(
args
.
request
))
end
=
time
.
time
()
end
=
time
.
time
()
if
latency_flags
:
if
latency_flags
:
return
[[
end
-
start
],
latency_list
]
return
[[
end
-
start
],
latency_list
]
...
@@ -82,9 +116,7 @@ def single_func(idx, resource):
...
@@ -82,9 +116,7 @@ def single_func(idx, resource):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
multi_thread_runner
=
MultiThreadRunner
()
multi_thread_runner
=
MultiThreadRunner
()
endpoint_list
=
[
endpoint_list
=
[
"127.0.0.1:9292"
]
"127.0.0.1:9292"
,
"127.0.0.1:9293"
,
"127.0.0.1:9294"
,
"127.0.0.1:9295"
]
turns
=
10
turns
=
10
start
=
time
.
time
()
start
=
time
.
time
()
result
=
multi_thread_runner
.
run
(
result
=
multi_thread_runner
.
run
(
...
...
python/examples/bert/bert_client.py
浏览文件 @
c107c3c4
...
@@ -14,15 +14,7 @@
...
@@ -14,15 +14,7 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
os
import
sys
import
sys
import
numpy
as
np
import
paddlehub
as
hub
import
ujson
import
random
import
time
from
paddlehub.common.logger
import
logger
import
socket
from
paddle_serving_client
import
Client
from
paddle_serving_client
import
Client
from
paddle_serving_client.utils
import
benchmark_args
from
paddle_serving_client.utils
import
benchmark_args
from
paddle_serving_app.reader
import
ChineseBertReader
from
paddle_serving_app.reader
import
ChineseBertReader
...
...
python/examples/imagenet/benchmark.py
浏览文件 @
c107c3c4
...
@@ -73,7 +73,7 @@ def single_func(idx, resource):
...
@@ -73,7 +73,7 @@ def single_func(idx, resource):
print
(
"unsupport batch size {}"
.
format
(
args
.
batch_size
))
print
(
"unsupport batch size {}"
.
format
(
args
.
batch_size
))
elif
args
.
request
==
"http"
:
elif
args
.
request
==
"http"
:
py_version
=
2
py_version
=
sys
.
version_info
[
0
]
server
=
"http://"
+
resource
[
"endpoint"
][
idx
%
len
(
resource
[
server
=
"http://"
+
resource
[
"endpoint"
][
idx
%
len
(
resource
[
"endpoint"
])]
+
"/image/prediction"
"endpoint"
])]
+
"/image/prediction"
start
=
time
.
time
()
start
=
time
.
time
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录