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
7b86f5e6
Commit
7b86f5e6
authored
Nov 04, 2011
by
antirez
Browse files
csv output for redis-benchmark
parent
410dfe90
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/redis-benchmark.c
View file @
7b86f5e6
...
@@ -68,6 +68,7 @@ static struct config {
...
@@ -68,6 +68,7 @@ static struct config {
const
char
*
title
;
const
char
*
title
;
list
*
clients
;
list
*
clients
;
int
quiet
;
int
quiet
;
int
csv
;
int
loop
;
int
loop
;
int
idlemode
;
int
idlemode
;
}
config
;
}
config
;
...
@@ -295,7 +296,7 @@ static void showLatencyReport(void) {
...
@@ -295,7 +296,7 @@ static void showLatencyReport(void) {
float
perc
,
reqpersec
;
float
perc
,
reqpersec
;
reqpersec
=
(
float
)
config
.
requests_finished
/
((
float
)
config
.
totlatency
/
1000
);
reqpersec
=
(
float
)
config
.
requests_finished
/
((
float
)
config
.
totlatency
/
1000
);
if
(
!
config
.
quiet
)
{
if
(
!
config
.
quiet
&&
!
config
.
csv
)
{
printf
(
"====== %s ======
\n
"
,
config
.
title
);
printf
(
"====== %s ======
\n
"
,
config
.
title
);
printf
(
" %d requests completed in %.2f seconds
\n
"
,
config
.
requests_finished
,
printf
(
" %d requests completed in %.2f seconds
\n
"
,
config
.
requests_finished
,
(
float
)
config
.
totlatency
/
1000
);
(
float
)
config
.
totlatency
/
1000
);
...
@@ -313,6 +314,8 @@ static void showLatencyReport(void) {
...
@@ -313,6 +314,8 @@ static void showLatencyReport(void) {
}
}
}
}
printf
(
"%.2f requests per second
\n\n
"
,
reqpersec
);
printf
(
"%.2f requests per second
\n\n
"
,
reqpersec
);
}
else
if
(
config
.
csv
)
{
printf
(
"
\"
%s
\"
,
\"
%.2f
\"\n
"
,
config
.
title
,
reqpersec
);
}
else
{
}
else
{
printf
(
"%s: %.2f requests per second
\n
"
,
config
.
title
,
reqpersec
);
printf
(
"%s: %.2f requests per second
\n
"
,
config
.
title
,
reqpersec
);
}
}
...
@@ -376,6 +379,8 @@ int parseOptions(int argc, const char **argv) {
...
@@ -376,6 +379,8 @@ int parseOptions(int argc, const char **argv) {
config
.
randomkeys_keyspacelen
=
0
;
config
.
randomkeys_keyspacelen
=
0
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"-q"
))
{
}
else
if
(
!
strcmp
(
argv
[
i
],
"-q"
))
{
config
.
quiet
=
1
;
config
.
quiet
=
1
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"--csv"
))
{
config
.
csv
=
1
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"-l"
))
{
}
else
if
(
!
strcmp
(
argv
[
i
],
"-l"
))
{
config
.
loop
=
1
;
config
.
loop
=
1
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"-I"
))
{
}
else
if
(
!
strcmp
(
argv
[
i
],
"-I"
))
{
...
@@ -414,6 +419,7 @@ usage:
...
@@ -414,6 +419,7 @@ usage:
printf
(
" if set to 10 only rand000000000000 - rand000000000009
\n
"
);
printf
(
" if set to 10 only rand000000000000 - rand000000000009
\n
"
);
printf
(
" range will be allowed.
\n
"
);
printf
(
" range will be allowed.
\n
"
);
printf
(
" -q Quiet. Just show query/sec values
\n
"
);
printf
(
" -q Quiet. Just show query/sec values
\n
"
);
printf
(
" --csv Output in CSV format
\n
"
);
printf
(
" -l Loop. Run the tests forever
\n
"
);
printf
(
" -l Loop. Run the tests forever
\n
"
);
printf
(
" -I Idle mode. Just open N idle connections and wait.
\n
"
);
printf
(
" -I Idle mode. Just open N idle connections and wait.
\n
"
);
exit
(
exit_status
);
exit
(
exit_status
);
...
@@ -424,6 +430,7 @@ int showThroughput(struct aeEventLoop *eventLoop, long long id, void *clientData
...
@@ -424,6 +430,7 @@ int showThroughput(struct aeEventLoop *eventLoop, long long id, void *clientData
REDIS_NOTUSED
(
id
);
REDIS_NOTUSED
(
id
);
REDIS_NOTUSED
(
clientData
);
REDIS_NOTUSED
(
clientData
);
if
(
config
.
csv
)
return
250
;
float
dt
=
(
float
)(
mstime
()
-
config
.
start
)
/
1000
.
0
;
float
dt
=
(
float
)(
mstime
()
-
config
.
start
)
/
1000
.
0
;
float
rps
=
(
float
)
config
.
requests_finished
/
dt
;
float
rps
=
(
float
)
config
.
requests_finished
/
dt
;
printf
(
"%s: %.2f
\r
"
,
config
.
title
,
rps
);
printf
(
"%s: %.2f
\r
"
,
config
.
title
,
rps
);
...
@@ -451,6 +458,7 @@ int main(int argc, const char **argv) {
...
@@ -451,6 +458,7 @@ int main(int argc, const char **argv) {
config
.
randomkeys
=
0
;
config
.
randomkeys
=
0
;
config
.
randomkeys_keyspacelen
=
0
;
config
.
randomkeys_keyspacelen
=
0
;
config
.
quiet
=
0
;
config
.
quiet
=
0
;
config
.
csv
=
0
;
config
.
loop
=
0
;
config
.
loop
=
0
;
config
.
idlemode
=
0
;
config
.
idlemode
=
0
;
config
.
latency
=
NULL
;
config
.
latency
=
NULL
;
...
@@ -564,7 +572,7 @@ int main(int argc, const char **argv) {
...
@@ -564,7 +572,7 @@ int main(int argc, const char **argv) {
benchmark
(
"LRANGE (first 600 elements)"
,
cmd
,
len
);
benchmark
(
"LRANGE (first 600 elements)"
,
cmd
,
len
);
free
(
cmd
);
free
(
cmd
);
printf
(
"
\n
"
);
if
(
!
config
.
csv
)
printf
(
"
\n
"
);
}
while
(
config
.
loop
);
}
while
(
config
.
loop
);
return
0
;
return
0
;
...
...
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