Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
想上天的蜗牛@
redis
提交
23803889
R
redis
项目概览
想上天的蜗牛@
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
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,体验更适合开发者的 AI 搜索 >>
提交
23803889
编写于
12月 23, 2010
作者:
P
Pieter Noordhuis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Randomize keys and set start time when first write event fires
上级
3c49070b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
5 addition
and
15 deletion
+5
-15
src/redis-benchmark.c
src/redis-benchmark.c
+5
-15
未找到文件。
src/redis-benchmark.c
浏览文件 @
23803889
...
...
@@ -45,10 +45,6 @@
#include "adlist.h"
#include "zmalloc.h"
#define CLIENT_CONNECTING 0
#define CLIENT_SENDQUERY 1
#define CLIENT_READREPLY 2
#define REDIS_NOTUSED(V) ((void) V)
static
struct
config
{
...
...
@@ -78,7 +74,6 @@ static struct config {
typedef
struct
_client
{
redisContext
*
context
;
int
state
;
sds
obuf
;
char
*
randptr
[
10
];
/* needed for MSET against 10 keys */
size_t
randlen
;
...
...
@@ -140,9 +135,6 @@ static void resetClient(client c) {
aeDeleteFileEvent
(
config
.
el
,
c
->
context
->
fd
,
AE_READABLE
);
aeCreateFileEvent
(
config
.
el
,
c
->
context
->
fd
,
AE_WRITABLE
,
writeHandler
,
c
);
c
->
written
=
0
;
c
->
state
=
CLIENT_SENDQUERY
;
c
->
start
=
ustime
();
c
->
latency
=
-
1
;
}
static
void
randomizeClientKey
(
client
c
)
{
...
...
@@ -164,7 +156,6 @@ static void clientDone(client c) {
}
if
(
config
.
keepalive
)
{
resetClient
(
c
);
if
(
config
.
randomkeys
)
randomizeClientKey
(
c
);
}
else
{
config
.
liveclients
--
;
createMissingClients
(
c
);
...
...
@@ -212,11 +203,13 @@ static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
REDIS_NOTUSED
(
fd
);
REDIS_NOTUSED
(
mask
);
if
(
c
->
state
==
CLIENT_CONNECTING
)
{
c
->
state
=
CLIENT_SENDQUERY
;
/* When nothing was written yet, randomize keys and set start time. */
if
(
c
->
written
==
0
)
{
if
(
config
.
randomkeys
)
randomizeClientKey
(
c
);
c
->
start
=
ustime
();
c
->
latency
=
-
1
;
}
if
(
sdslen
(
c
->
obuf
)
>
c
->
written
)
{
void
*
ptr
=
c
->
obuf
+
c
->
written
;
int
nwritten
=
write
(
c
->
context
->
fd
,
ptr
,
sdslen
(
c
->
obuf
)
-
c
->
written
);
...
...
@@ -230,7 +223,6 @@ static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
if
(
sdslen
(
c
->
obuf
)
==
c
->
written
)
{
aeDeleteFileEvent
(
config
.
el
,
c
->
context
->
fd
,
AE_WRITABLE
);
aeCreateFileEvent
(
config
.
el
,
c
->
context
->
fd
,
AE_READABLE
,
readHandler
,
c
);
c
->
state
=
CLIENT_READREPLY
;
}
}
}
...
...
@@ -250,7 +242,6 @@ static client createClient(char *cmd, int len) {
fprintf
(
stderr
,
"%s: %s
\n
"
,
config
.
hostsocket
,
c
->
context
->
errstr
);
exit
(
1
);
}
c
->
state
=
CLIENT_CONNECTING
;
c
->
obuf
=
sdsnewlen
(
cmd
,
len
);
c
->
randlen
=
0
;
c
->
written
=
0
;
...
...
@@ -278,8 +269,7 @@ static void createMissingClients(client c) {
int
n
=
0
;
while
(
config
.
liveclients
<
config
.
numclients
)
{
client
new
=
createClient
(
c
->
obuf
,
sdslen
(
c
->
obuf
));
if
(
config
.
randomkeys
)
randomizeClientKey
(
new
);
createClient
(
c
->
obuf
,
sdslen
(
c
->
obuf
));
/* Listen backlog is quite limited on most systems */
if
(
++
n
>
64
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录