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
redis
Commits
174df6fe
Commit
174df6fe
authored
Dec 16, 2010
by
Pieter Noordhuis
Browse files
Re-use variable data in redis-benchmark
parent
53f1d817
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/redis-benchmark.c
View file @
174df6fe
...
@@ -397,6 +397,7 @@ int showThroughput(struct aeEventLoop *eventLoop, long long id, void *clientData
...
@@ -397,6 +397,7 @@ int showThroughput(struct aeEventLoop *eventLoop, long long id, void *clientData
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
int
i
;
client
c
;
client
c
;
signal
(
SIGHUP
,
SIG_IGN
);
signal
(
SIGHUP
,
SIG_IGN
);
...
@@ -440,6 +441,10 @@ int main(int argc, char **argv) {
...
@@ -440,6 +441,10 @@ int main(int argc, char **argv) {
}
}
do
{
do
{
char
*
data
=
zmalloc
(
config
.
datasize
+
1
);
memset
(
data
,
'x'
,
config
.
datasize
);
data
[
config
.
datasize
]
=
'\0'
;
prepareForBenchmark
(
"PING"
);
prepareForBenchmark
(
"PING"
);
c
=
createClient
(
REDIS_REPLY_STATUS
);
c
=
createClient
(
REDIS_REPLY_STATUS
);
c
->
obuf
=
sdscat
(
c
->
obuf
,
"PING
\r\n
"
);
c
->
obuf
=
sdscat
(
c
->
obuf
,
"PING
\r\n
"
);
...
@@ -457,16 +462,8 @@ int main(int argc, char **argv) {
...
@@ -457,16 +462,8 @@ int main(int argc, char **argv) {
prepareForBenchmark
(
"MSET (10 keys, multi bulk)"
);
prepareForBenchmark
(
"MSET (10 keys, multi bulk)"
);
c
=
createClient
(
REDIS_REPLY_ARRAY
);
c
=
createClient
(
REDIS_REPLY_ARRAY
);
c
->
obuf
=
sdscatprintf
(
c
->
obuf
,
"*%d
\r\n
$4
\r\n
MSET
\r\n
"
,
11
);
c
->
obuf
=
sdscatprintf
(
c
->
obuf
,
"*%d
\r\n
$4
\r\n
MSET
\r\n
"
,
11
);
{
for
(
i
=
0
;
i
<
10
;
i
++
)
{
int
i
;
c
->
obuf
=
sdscatprintf
(
c
->
obuf
,
"$%d
\r\n
%s
\r\n
"
,
config
.
datasize
,
data
);
char
*
data
=
zmalloc
(
config
.
datasize
+
1
);
memset
(
data
,
'x'
,
config
.
datasize
);
data
[
config
.
datasize
]
=
'\0'
;
for
(
i
=
0
;
i
<
10
;
i
++
)
{
c
->
obuf
=
sdscatprintf
(
c
->
obuf
,
"$%d
\r\n
%s
\r\n
"
,
config
.
datasize
,
data
);
}
zfree
(
data
);
}
createMissingClients
(
c
);
createMissingClients
(
c
);
aeMain
(
config
.
el
);
aeMain
(
config
.
el
);
endBenchmark
();
endBenchmark
();
...
@@ -474,14 +471,7 @@ int main(int argc, char **argv) {
...
@@ -474,14 +471,7 @@ int main(int argc, char **argv) {
prepareForBenchmark
(
"SET"
);
prepareForBenchmark
(
"SET"
);
c
=
createClient
(
REDIS_REPLY_STATUS
);
c
=
createClient
(
REDIS_REPLY_STATUS
);
c
->
obuf
=
sdscat
(
c
->
obuf
,
"*3
\r\n
$3
\r\n
SET
\r\n
$20
\r\n
foo_rand000000000000
\r\n
"
);
c
->
obuf
=
sdscat
(
c
->
obuf
,
"*3
\r\n
$3
\r\n
SET
\r\n
$20
\r\n
foo_rand000000000000
\r\n
"
);
{
c
->
obuf
=
sdscatprintf
(
c
->
obuf
,
"$%d
\r\n
%s
\r\n
"
,
config
.
datasize
,
data
);
char
*
data
=
zmalloc
(
config
.
datasize
+
2
);
memset
(
data
,
'x'
,
config
.
datasize
);
data
[
config
.
datasize
]
=
'\r'
;
data
[
config
.
datasize
+
1
]
=
'\n'
;
c
->
obuf
=
sdscatprintf
(
c
->
obuf
,
"$%d
\r\n
"
,
config
.
datasize
);
c
->
obuf
=
sdscatlen
(
c
->
obuf
,
data
,
config
.
datasize
+
2
);
}
createMissingClients
(
c
);
createMissingClients
(
c
);
aeMain
(
config
.
el
);
aeMain
(
config
.
el
);
endBenchmark
();
endBenchmark
();
...
...
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