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
You need to sign in or sign up before continuing.
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
}
int
main
(
int
argc
,
char
**
argv
)
{
int
i
;
client
c
;
signal
(
SIGHUP
,
SIG_IGN
);
...
...
@@ -440,6 +441,10 @@ int main(int argc, char **argv) {
}
do
{
char
*
data
=
zmalloc
(
config
.
datasize
+
1
);
memset
(
data
,
'x'
,
config
.
datasize
);
data
[
config
.
datasize
]
=
'\0'
;
prepareForBenchmark
(
"PING"
);
c
=
createClient
(
REDIS_REPLY_STATUS
);
c
->
obuf
=
sdscat
(
c
->
obuf
,
"PING
\r\n
"
);
...
...
@@ -457,16 +462,8 @@ int main(int argc, char **argv) {
prepareForBenchmark
(
"MSET (10 keys, multi bulk)"
);
c
=
createClient
(
REDIS_REPLY_ARRAY
);
c
->
obuf
=
sdscatprintf
(
c
->
obuf
,
"*%d
\r\n
$4
\r\n
MSET
\r\n
"
,
11
);
{
int
i
;
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
);
}
for
(
i
=
0
;
i
<
10
;
i
++
)
{
c
->
obuf
=
sdscatprintf
(
c
->
obuf
,
"$%d
\r\n
%s
\r\n
"
,
config
.
datasize
,
data
);
createMissingClients
(
c
);
aeMain
(
config
.
el
);
endBenchmark
();
...
...
@@ -474,14 +471,7 @@ int main(int argc, char **argv) {
prepareForBenchmark
(
"SET"
);
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
"
);
{
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
);
}
c
->
obuf
=
sdscatprintf
(
c
->
obuf
,
"$%d
\r\n
%s
\r\n
"
,
config
.
datasize
,
data
);
createMissingClients
(
c
);
aeMain
(
config
.
el
);
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