Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
9f5ed60e
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
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看板
未验证
提交
9f5ed60e
编写于
10月 15, 2019
作者:
W
Wang Guibao
提交者:
GitHub
10月 15, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update get_value.cpp
上级
2eef5aef
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
26 addition
and
14 deletion
+26
-14
doc/resource/get_value.cpp
doc/resource/get_value.cpp
+26
-14
未找到文件。
doc/resource/get_value.cpp
浏览文件 @
9f5ed60e
...
@@ -19,6 +19,8 @@ int pool_size = 5;
...
@@ -19,6 +19,8 @@ int pool_size = 5;
int
batch_size
=
100
;
int
batch_size
=
100
;
int
key_size
=
10000000
;
// keys in redis server
int
key_size
=
10000000
;
// keys in redis server
std
::
vector
<
uint64_t
>
times_us
;
sw
::
redis
::
Redis
*
redis
;
sw
::
redis
::
Redis
*
redis
;
int
parse_options
(
int
argc
,
char
**
argv
)
int
parse_options
(
int
argc
,
char
**
argv
)
...
@@ -84,29 +86,25 @@ int parse_options(int argc, char **argv)
...
@@ -84,29 +86,25 @@ int parse_options(int argc, char **argv)
return
0
;
return
0
;
}
}
void
thread_worker
()
void
thread_worker
(
int
thread_id
)
{
{
// get values
// get values
for
(
int
i
=
0
;
i
<
total_request_num
;
++
i
)
{
std
::
vector
<
std
::
string
>
get_kvs
;
std
::
vector
<
std
::
string
>
get_kvs
;
std
::
vector
<
std
::
string
>
get_kvs_res
;
std
::
vector
<
std
::
string
>
get_kvs_res
;
get_kvs_res
.
reserve
(
total_request_num
);
uint64_t
time_us
=
0
;
for
(
int
i
=
0
;
i
<
total_request_num
;
++
i
)
{
get_kvs
.
clear
();
get_kvs_res
.
clear
();
for
(
int
j
=
i
*
batch_size
;
j
<
(
i
+
1
)
*
batch_size
;
j
++
)
{
for
(
int
j
=
i
*
batch_size
;
j
<
(
i
+
1
)
*
batch_size
;
j
++
)
{
get_kvs
.
push_back
(
std
::
to_string
(
i
%
key_size
));
get_kvs
.
push_back
(
std
::
to_string
(
i
%
key_size
));
}
}
auto
start2
=
std
::
chrono
::
steady_clock
::
now
();
auto
start2
=
std
::
chrono
::
steady_clock
::
now
();
redis
->
mget
(
get_kvs
.
begin
(),
get_kvs
.
end
(),
get_kvs_res
.
begin
(
));
redis
->
mget
(
get_kvs
.
begin
(),
get_kvs
.
end
(),
std
::
back_inserter
(
get_kvs_res
));
auto
stop2
=
std
::
chrono
::
steady_clock
::
now
();
auto
stop2
=
std
::
chrono
::
steady_clock
::
now
();
time
_us
+=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
stop2
-
start2
).
count
();
time
s_us
[
thread_id
]
+=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
stop2
-
start2
).
count
();
}
}
std
::
cout
<<
total_request_num
<<
" requests, "
<<
batch_size
<<
" keys per req, total time us = "
<<
time_us
<<
std
::
endl
;
std
::
cout
<<
total_request_num
<<
" requests, "
<<
batch_size
<<
" keys per req, total time us = "
<<
times_us
[
thread_id
]
<<
std
::
endl
;
std
::
cout
<<
"Average "
<<
time_us
/
total_request_num
<<
"us per req"
<<
std
::
endl
;
std
::
cout
<<
"Average "
<<
times_us
[
thread_id
]
/
total_request_num
<<
"us per req"
<<
std
::
endl
;
std
::
cout
<<
"qps: "
<<
(
double
)
total_request_num
/
times_us
[
thread_id
]
*
1000000
<<
std
::
endl
;
}
}
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
...
@@ -117,13 +115,27 @@ int main(int argc, char **argv)
...
@@ -117,13 +115,27 @@ int main(int argc, char **argv)
redis
=
new
sw
::
redis
::
Redis
(
connstr
);
redis
=
new
sw
::
redis
::
Redis
(
connstr
);
std
::
vector
<
std
::
thread
>
workers
;
std
::
vector
<
std
::
thread
>
workers
;
times_us
.
reserve
(
thread_num
);
for
(
int
i
=
0
;
i
<
thread_num
;
++
i
)
{
for
(
int
i
=
0
;
i
<
thread_num
;
++
i
)
{
workers
.
push_back
(
std
::
thread
(
thread_worker
));
times_us
[
i
]
=
0
;
workers
.
push_back
(
std
::
thread
(
thread_worker
,
i
));
}
}
for
(
int
i
=
0
;
i
<
thread_num
;
++
i
)
{
for
(
int
i
=
0
;
i
<
thread_num
;
++
i
)
{
workers
[
i
].
join
();
workers
[
i
].
join
();
}
}
uint64_t
times_total_us
=
0
;
for
(
int
i
=
0
;
i
<
thread_num
;
++
i
)
{
times_total_us
+=
times_us
[
i
];
}
times_total_us
/=
thread_num
;
total_request_num
*=
thread_num
;
std
::
cout
<<
total_request_num
<<
" requests, "
<<
batch_size
<<
" keys per req, total time us = "
<<
times_total_us
<<
std
::
endl
;
std
::
cout
<<
"Average "
<<
times_total_us
/
total_request_num
<<
"us per req"
<<
std
::
endl
;
std
::
cout
<<
"qps: "
<<
(
double
)
total_request_num
/
times_total_us
*
1000000
<<
std
::
endl
;
return
0
;
return
0
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录