Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
58cd7103
R
redis
项目概览
xindoo
/
redis
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
58cd7103
编写于
11月 19, 2009
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debug mode in redis-bench
上级
7ea870c0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
15 addition
and
0 deletion
+15
-0
benchmark.c
benchmark.c
+15
-0
未找到文件。
benchmark.c
浏览文件 @
58cd7103
...
...
@@ -59,6 +59,7 @@
#define REDIS_NOTUSED(V) ((void) V)
static
struct
config
{
int
debug
;
int
numclients
;
int
requests
;
int
liveclients
;
...
...
@@ -86,6 +87,7 @@ typedef struct _client {
sds
ibuf
;
int
mbulk
;
/* Number of elements in an mbulk reply */
int
readlen
;
/* readlen == -1 means read a single line */
int
totreceived
;
unsigned
int
written
;
/* bytes of 'obuf' already written */
int
replytype
;
long
long
start
;
/* start time in milliseconds */
...
...
@@ -141,6 +143,7 @@ static void resetClient(client c) {
c
->
replytype
==
REPLY_MBULK
)
?
-
1
:
0
;
c
->
mbulk
=
-
1
;
c
->
written
=
0
;
c
->
totreceived
=
0
;
c
->
state
=
CLIENT_SENDQUERY
;
c
->
start
=
mstime
();
createMissingClients
(
c
);
...
...
@@ -174,12 +177,18 @@ static void prepareClientForReply(client c, int type) {
}
static
void
clientDone
(
client
c
)
{
static
int
last_tot_received
=
1
;
long
long
latency
;
config
.
donerequests
++
;
latency
=
mstime
()
-
c
->
start
;
if
(
latency
>
MAX_LATENCY
)
latency
=
MAX_LATENCY
;
config
.
latency
[
latency
]
++
;
if
(
config
.
debug
&&
last_tot_received
!=
c
->
totreceived
)
{
printf
(
"Tot bytes received: %d
\n
"
,
c
->
totreceived
);
last_tot_received
=
c
->
totreceived
;
}
if
(
config
.
donerequests
==
config
.
requests
)
{
freeClient
(
c
);
aeStop
(
config
.
el
);
...
...
@@ -216,6 +225,7 @@ static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask)
freeClient
(
c
);
return
;
}
c
->
totreceived
+=
nread
;
c
->
ibuf
=
sdscatlen
(
c
->
ibuf
,
buf
,
nread
);
processdata:
...
...
@@ -340,6 +350,7 @@ static client createClient(void) {
c
->
mbulk
=
-
1
;
c
->
readlen
=
0
;
c
->
written
=
0
;
c
->
totreceived
=
0
;
c
->
state
=
CLIENT_CONNECTING
;
aeCreateFileEvent
(
config
.
el
,
c
->
fd
,
AE_WRITABLE
,
writeHandler
,
c
,
NULL
);
config
.
liveclients
++
;
...
...
@@ -440,6 +451,8 @@ void parseOptions(int argc, char **argv) {
config
.
quiet
=
1
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"-l"
))
{
config
.
loop
=
1
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"-D"
))
{
config
.
debug
=
1
;
}
else
{
printf
(
"Wrong option '%s' or option argument missing
\n\n
"
,
argv
[
i
]);
printf
(
"Usage: redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests]> [-k <boolean>]
\n\n
"
);
...
...
@@ -458,6 +471,7 @@ void parseOptions(int argc, char **argv) {
printf
(
" range will be allowed.
\n
"
);
printf
(
" -q Quiet. Just show query/sec values
\n
"
);
printf
(
" -l Loop. Run the tests forever
\n
"
);
printf
(
" -D Debug mode. more verbose.
\n
"
);
exit
(
1
);
}
}
...
...
@@ -469,6 +483,7 @@ int main(int argc, char **argv) {
signal
(
SIGHUP
,
SIG_IGN
);
signal
(
SIGPIPE
,
SIG_IGN
);
config
.
debug
=
0
;
config
.
numclients
=
50
;
config
.
requests
=
10000
;
config
.
liveclients
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录