Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
b34a8c3b
Commit
b34a8c3b
authored
May 09, 2013
by
CharSyam
Committed by
antirez
Aug 25, 2014
Browse files
redis-benchmark: add auth option
Closes #1097
parent
7e63dd23
Changes
1
Show whitespace changes
Inline
Side-by-side
src/redis-benchmark.c
View file @
b34a8c3b
...
@@ -77,6 +77,7 @@ static struct config {
...
@@ -77,6 +77,7 @@ static struct config {
int
dbnum
;
int
dbnum
;
sds
dbnumstr
;
sds
dbnumstr
;
char
*
tests
;
char
*
tests
;
char
*
auth
;
}
config
;
}
config
;
typedef
struct
_client
{
typedef
struct
_client
{
...
@@ -325,6 +326,13 @@ static client createClient(char *cmd, size_t len, client from) {
...
@@ -325,6 +326,13 @@ static client createClient(char *cmd, size_t len, client from) {
* the example client buffer. */
* the example client buffer. */
c
->
obuf
=
sdsempty
();
c
->
obuf
=
sdsempty
();
if
(
config
.
auth
)
{
char
*
buf
=
NULL
;
int
len
=
redisFormatCommand
(
&
buf
,
"AUTH %s"
,
config
.
auth
);
c
->
obuf
=
sdscatlen
(
c
->
obuf
,
buf
,
len
);
free
(
buf
);
}
/* If a DB number different than zero is selected, prefix our request
/* If a DB number different than zero is selected, prefix our request
* buffer with the SELECT command, that will be discarded the first
* buffer with the SELECT command, that will be discarded the first
* time the replies are received, so if the client is reused the
* time the replies are received, so if the client is reused the
...
@@ -346,6 +354,7 @@ static client createClient(char *cmd, size_t len, client from) {
...
@@ -346,6 +354,7 @@ static client createClient(char *cmd, size_t len, client from) {
for
(
j
=
0
;
j
<
config
.
pipeline
;
j
++
)
for
(
j
=
0
;
j
<
config
.
pipeline
;
j
++
)
c
->
obuf
=
sdscatlen
(
c
->
obuf
,
cmd
,
len
);
c
->
obuf
=
sdscatlen
(
c
->
obuf
,
cmd
,
len
);
}
}
c
->
written
=
0
;
c
->
written
=
0
;
c
->
pending
=
config
.
pipeline
;
c
->
pending
=
config
.
pipeline
;
c
->
randptr
=
NULL
;
c
->
randptr
=
NULL
;
...
@@ -489,6 +498,9 @@ int parseOptions(int argc, const char **argv) {
...
@@ -489,6 +498,9 @@ int parseOptions(int argc, const char **argv) {
}
else
if
(
!
strcmp
(
argv
[
i
],
"-s"
))
{
}
else
if
(
!
strcmp
(
argv
[
i
],
"-s"
))
{
if
(
lastarg
)
goto
invalid
;
if
(
lastarg
)
goto
invalid
;
config
.
hostsocket
=
strdup
(
argv
[
++
i
]);
config
.
hostsocket
=
strdup
(
argv
[
++
i
]);
}
else
if
(
!
strcmp
(
argv
[
i
],
"-a"
)
)
{
if
(
lastarg
)
goto
invalid
;
config
.
auth
=
strdup
(
argv
[
++
i
]);
}
else
if
(
!
strcmp
(
argv
[
i
],
"-d"
))
{
}
else
if
(
!
strcmp
(
argv
[
i
],
"-d"
))
{
if
(
lastarg
)
goto
invalid
;
if
(
lastarg
)
goto
invalid
;
config
.
datasize
=
atoi
(
argv
[
++
i
]);
config
.
datasize
=
atoi
(
argv
[
++
i
]);
...
@@ -550,6 +562,7 @@ usage:
...
@@ -550,6 +562,7 @@ usage:
" -h <hostname> Server hostname (default 127.0.0.1)
\n
"
" -h <hostname> Server hostname (default 127.0.0.1)
\n
"
" -p <port> Server port (default 6379)
\n
"
" -p <port> Server port (default 6379)
\n
"
" -s <socket> Server socket (overrides host and port)
\n
"
" -s <socket> Server socket (overrides host and port)
\n
"
" -a <password> Password for Redis Auth
\n
"
" -c <clients> Number of parallel connections (default 50)
\n
"
" -c <clients> Number of parallel connections (default 50)
\n
"
" -n <requests> Total number of requests (default 10000)
\n
"
" -n <requests> Total number of requests (default 10000)
\n
"
" -d <size> Data size of SET/GET value in bytes (default 2)
\n
"
" -d <size> Data size of SET/GET value in bytes (default 2)
\n
"
...
@@ -651,6 +664,7 @@ int main(int argc, const char **argv) {
...
@@ -651,6 +664,7 @@ int main(int argc, const char **argv) {
config
.
hostsocket
=
NULL
;
config
.
hostsocket
=
NULL
;
config
.
tests
=
NULL
;
config
.
tests
=
NULL
;
config
.
dbnum
=
0
;
config
.
dbnum
=
0
;
config
.
auth
=
NULL
;
i
=
parseOptions
(
argc
,
argv
);
i
=
parseOptions
(
argc
,
argv
);
argc
-=
i
;
argc
-=
i
;
...
...
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