Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
0e8afce0
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看板
未验证
提交
0e8afce0
编写于
10月 18, 2019
作者:
W
Wang Guibao
提交者:
GitHub
10月 18, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update get_value.cpp
上级
8ce3d5e5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
9 deletion
+13
-9
doc/resource/get_value.cpp
doc/resource/get_value.cpp
+13
-9
未找到文件。
doc/resource/get_value.cpp
浏览文件 @
0e8afce0
...
@@ -20,6 +20,7 @@ int batch_size = 100;
...
@@ -20,6 +20,7 @@ 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
;
std
::
vector
<
uint64_t
>
times_us
;
std
::
vector
<
uint64_t
>
average_time_us
;
sw
::
redis
::
Redis
*
redis
;
sw
::
redis
::
Redis
*
redis
;
...
@@ -94,7 +95,7 @@ void thread_worker(int thread_id)
...
@@ -94,7 +95,7 @@ void thread_worker(int thread_id)
std
::
vector
<
std
::
string
>
get_kvs_res
;
std
::
vector
<
std
::
string
>
get_kvs_res
;
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
(
j
%
key_size
));
}
}
auto
start2
=
std
::
chrono
::
steady_clock
::
now
();
auto
start2
=
std
::
chrono
::
steady_clock
::
now
();
redis
->
mget
(
get_kvs
.
begin
(),
get_kvs
.
end
(),
std
::
back_inserter
(
get_kvs_res
));
redis
->
mget
(
get_kvs
.
begin
(),
get_kvs
.
end
(),
std
::
back_inserter
(
get_kvs_res
));
...
@@ -102,10 +103,11 @@ void thread_worker(int thread_id)
...
@@ -102,10 +103,11 @@ void thread_worker(int thread_id)
times_us
[
thread_id
]
+=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
stop2
-
start2
).
count
();
times_us
[
thread_id
]
+=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
stop2
-
start2
).
count
();
}
}
// Per-thread statistics
average_time_us
[
thread_id
]
=
times_us
[
thread_id
]
/
total_request_num
;
std
::
cout
<<
total_request_num
<<
" requests, "
<<
batch_size
<<
" keys per req, total time us = "
<<
times_us
[
thread_id
]
<<
std
::
endl
;
std
::
cout
<<
"Average "
<<
times_us
[
thread_id
]
/
total_request_num
<<
"us per req"
<<
std
::
endl
;
// std::cout << total_request_num << " requests, " << batch_size << " keys per req, total time us = " << times_us[thread_id] <<std::endl;
std
::
cout
<<
"qps: "
<<
(
double
)
total_request_num
/
times_us
[
thread_id
]
*
1000000
<<
std
::
endl
;
// std::cout << "Average " << average_time_us[thread_id] << "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,6 +119,7 @@ int main(int argc, char **argv)
...
@@ -117,6 +119,7 @@ int main(int argc, char **argv)
std
::
vector
<
std
::
thread
>
workers
;
std
::
vector
<
std
::
thread
>
workers
;
times_us
.
reserve
(
thread_num
);
times_us
.
reserve
(
thread_num
);
average_time_us
.
reserve
(
thread_num
);
for
(
int
i
=
0
;
i
<
thread_num
;
++
i
)
{
for
(
int
i
=
0
;
i
<
thread_num
;
++
i
)
{
times_us
[
i
]
=
0
;
times_us
[
i
]
=
0
;
...
@@ -127,18 +130,19 @@ int main(int argc, char **argv)
...
@@ -127,18 +130,19 @@ int main(int argc, char **argv)
workers
[
i
].
join
();
workers
[
i
].
join
();
}
}
// times_total_us is average running time of each thread
uint64_t
times_total_us
=
0
;
uint64_t
times_total_us
=
0
;
uint64_t
average_time_total_us
;
for
(
int
i
=
0
;
i
<
thread_num
;
++
i
)
{
for
(
int
i
=
0
;
i
<
thread_num
;
++
i
)
{
times_total_us
+=
times_us
[
i
];
times_total_us
+=
times_us
[
i
];
average_time_total_us
+=
average_time_us
[
i
];
}
}
times_total_us
/=
thread_num
;
times_total_us
/=
thread_num
;
// Total requests should be sum of requests sent by each thread
total_request_num
*=
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
<<
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
<<
"Average "
<<
average_time_total_us
/
thread
_num
<<
"us per req"
<<
std
::
endl
;
std
::
cout
<<
"qps: "
<<
(
double
)
total_request_num
/
times_total_us
*
1000000
<<
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录