Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
17802424
Commit
17802424
authored
Apr 19, 2011
by
Pieter Noordhuis
Browse files
Use variable for throughput test iteration count
parent
cd7063e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
test.c
View file @
17802424
...
...
@@ -336,7 +336,7 @@ static void test_reply_reader(void) {
}
static
void
test_throughput
(
void
)
{
int
i
;
int
i
,
num
;
long
long
t1
,
t2
;
redisContext
*
c
=
blocking_context
;
redisReply
**
replies
;
...
...
@@ -345,55 +345,57 @@ static void test_throughput(void) {
for
(
i
=
0
;
i
<
500
;
i
++
)
freeReplyObject
(
redisCommand
(
c
,
"LPUSH mylist foo"
));
replies
=
malloc
(
sizeof
(
redisReply
*
)
*
1000
);
num
=
1000
;
replies
=
malloc
(
sizeof
(
redisReply
*
)
*
num
);
t1
=
usec
();
for
(
i
=
0
;
i
<
1000
;
i
++
)
{
for
(
i
=
0
;
i
<
num
;
i
++
)
{
replies
[
i
]
=
redisCommand
(
c
,
"PING"
);
assert
(
replies
[
i
]
!=
NULL
&&
replies
[
i
]
->
type
==
REDIS_REPLY_STATUS
);
}
t2
=
usec
();
for
(
i
=
0
;
i
<
1000
;
i
++
)
freeReplyObject
(
replies
[
i
]);
for
(
i
=
0
;
i
<
num
;
i
++
)
freeReplyObject
(
replies
[
i
]);
free
(
replies
);
printf
(
"
\t
(
1000
x PING: %.3fs)
\n
"
,
(
t2
-
t1
)
/
1000000
.
0
);
printf
(
"
\t
(
%d
x PING: %.3fs)
\n
"
,
num
,
(
t2
-
t1
)
/
1000000
.
0
);
replies
=
malloc
(
sizeof
(
redisReply
*
)
*
1000
);
replies
=
malloc
(
sizeof
(
redisReply
*
)
*
num
);
t1
=
usec
();
for
(
i
=
0
;
i
<
1000
;
i
++
)
{
for
(
i
=
0
;
i
<
num
;
i
++
)
{
replies
[
i
]
=
redisCommand
(
c
,
"LRANGE mylist 0 499"
);
assert
(
replies
[
i
]
!=
NULL
&&
replies
[
i
]
->
type
==
REDIS_REPLY_ARRAY
);
assert
(
replies
[
i
]
!=
NULL
&&
replies
[
i
]
->
elements
==
500
);
}
t2
=
usec
();
for
(
i
=
0
;
i
<
1000
;
i
++
)
freeReplyObject
(
replies
[
i
]);
for
(
i
=
0
;
i
<
num
;
i
++
)
freeReplyObject
(
replies
[
i
]);
free
(
replies
);
printf
(
"
\t
(
1000
x LRANGE with 500 elements: %.3fs)
\n
"
,
(
t2
-
t1
)
/
1000000
.
0
);
printf
(
"
\t
(
%d
x LRANGE with 500 elements: %.3fs)
\n
"
,
num
,
(
t2
-
t1
)
/
1000000
.
0
);
replies
=
malloc
(
sizeof
(
redisReply
*
)
*
10000
);
for
(
i
=
0
;
i
<
10000
;
i
++
)
num
=
10000
;
replies
=
malloc
(
sizeof
(
redisReply
*
)
*
num
);
for
(
i
=
0
;
i
<
num
;
i
++
)
redisAppendCommand
(
c
,
"PING"
);
t1
=
usec
();
for
(
i
=
0
;
i
<
10000
;
i
++
)
{
for
(
i
=
0
;
i
<
num
;
i
++
)
{
assert
(
redisGetReply
(
c
,
(
void
*
)
&
replies
[
i
])
==
REDIS_OK
);
assert
(
replies
[
i
]
!=
NULL
&&
replies
[
i
]
->
type
==
REDIS_REPLY_STATUS
);
}
t2
=
usec
();
for
(
i
=
0
;
i
<
10000
;
i
++
)
freeReplyObject
(
replies
[
i
]);
for
(
i
=
0
;
i
<
num
;
i
++
)
freeReplyObject
(
replies
[
i
]);
free
(
replies
);
printf
(
"
\t
(
10000
x PING (pipelined): %.3fs)
\n
"
,
(
t2
-
t1
)
/
1000000
.
0
);
printf
(
"
\t
(
%d
x PING (pipelined): %.3fs)
\n
"
,
num
,
(
t2
-
t1
)
/
1000000
.
0
);
replies
=
malloc
(
sizeof
(
redisReply
*
)
*
10000
);
for
(
i
=
0
;
i
<
10000
;
i
++
)
replies
=
malloc
(
sizeof
(
redisReply
*
)
*
num
);
for
(
i
=
0
;
i
<
num
;
i
++
)
redisAppendCommand
(
c
,
"LRANGE mylist 0 499"
);
t1
=
usec
();
for
(
i
=
0
;
i
<
10000
;
i
++
)
{
for
(
i
=
0
;
i
<
num
;
i
++
)
{
assert
(
redisGetReply
(
c
,
(
void
*
)
&
replies
[
i
])
==
REDIS_OK
);
assert
(
replies
[
i
]
!=
NULL
&&
replies
[
i
]
->
type
==
REDIS_REPLY_ARRAY
);
assert
(
replies
[
i
]
!=
NULL
&&
replies
[
i
]
->
elements
==
500
);
}
t2
=
usec
();
for
(
i
=
0
;
i
<
10000
;
i
++
)
freeReplyObject
(
replies
[
i
]);
for
(
i
=
0
;
i
<
num
;
i
++
)
freeReplyObject
(
replies
[
i
]);
free
(
replies
);
printf
(
"
\t
(
10000
x LRANGE with 500 elements: %.3fs)
\n
"
,
(
t2
-
t1
)
/
1000000
.
0
);
printf
(
"
\t
(
%d
x LRANGE with 500 elements
(pipelined)
: %.3fs)
\n
"
,
num
,
(
t2
-
t1
)
/
1000000
.
0
);
}
static
void
cleanup
(
void
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment