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
c60a0f58
Commit
c60a0f58
authored
May 31, 2011
by
Pieter Noordhuis
Browse files
More const's in redis-benchmark.c
parent
942354f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/redis-benchmark.c
View file @
c60a0f58
...
@@ -48,6 +48,10 @@
...
@@ -48,6 +48,10 @@
#define REDIS_NOTUSED(V) ((void) V)
#define REDIS_NOTUSED(V) ((void) V)
static
struct
config
{
static
struct
config
{
aeEventLoop
*
el
;
const
char
*
hostip
;
int
hostport
;
const
char
*
hostsocket
;
int
debug
;
int
debug
;
int
numclients
;
int
numclients
;
int
requests
;
int
requests
;
...
@@ -57,15 +61,11 @@ static struct config {
...
@@ -57,15 +61,11 @@ static struct config {
int
datasize
;
int
datasize
;
int
randomkeys
;
int
randomkeys
;
int
randomkeys_keyspacelen
;
int
randomkeys_keyspacelen
;
aeEventLoop
*
el
;
char
*
hostip
;
int
hostport
;
char
*
hostsocket
;
int
keepalive
;
int
keepalive
;
long
long
start
;
long
long
start
;
long
long
totlatency
;
long
long
totlatency
;
long
long
*
latency
;
long
long
*
latency
;
char
*
title
;
const
char
*
title
;
list
*
clients
;
list
*
clients
;
int
quiet
;
int
quiet
;
int
loop
;
int
loop
;
...
@@ -227,7 +227,7 @@ static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
...
@@ -227,7 +227,7 @@ static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
}
}
}
}
static
client
createClient
(
char
*
cmd
,
in
t
len
)
{
static
client
createClient
(
const
char
*
cmd
,
size_
t
len
)
{
client
c
=
zmalloc
(
sizeof
(
struct
_client
));
client
c
=
zmalloc
(
sizeof
(
struct
_client
));
if
(
config
.
hostsocket
==
NULL
)
{
if
(
config
.
hostsocket
==
NULL
)
{
c
->
context
=
redisConnectNonBlock
(
config
.
hostip
,
config
.
hostport
);
c
->
context
=
redisConnectNonBlock
(
config
.
hostip
,
config
.
hostport
);
...
@@ -311,7 +311,7 @@ static void showLatencyReport(void) {
...
@@ -311,7 +311,7 @@ static void showLatencyReport(void) {
}
}
}
}
static
void
benchmark
(
char
*
title
,
char
*
cmd
,
int
len
)
{
static
void
benchmark
(
const
char
*
title
,
const
char
*
cmd
,
int
len
)
{
client
c
;
client
c
;
config
.
title
=
title
;
config
.
title
=
title
;
...
@@ -328,7 +328,7 @@ static void benchmark(char *title, char *cmd, int len) {
...
@@ -328,7 +328,7 @@ static void benchmark(char *title, char *cmd, int len) {
freeAllClients
();
freeAllClients
();
}
}
void
parseOptions
(
int
argc
,
char
**
argv
)
{
void
parseOptions
(
int
argc
,
const
char
**
argv
)
{
int
i
;
int
i
;
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
...
@@ -344,13 +344,13 @@ void parseOptions(int argc, char **argv) {
...
@@ -344,13 +344,13 @@ void parseOptions(int argc, char **argv) {
config
.
keepalive
=
atoi
(
argv
[
i
+
1
]);
config
.
keepalive
=
atoi
(
argv
[
i
+
1
]);
i
++
;
i
++
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"-h"
)
&&
!
lastarg
)
{
}
else
if
(
!
strcmp
(
argv
[
i
],
"-h"
)
&&
!
lastarg
)
{
config
.
hostip
=
argv
[
i
+
1
];
config
.
hostip
=
strdup
(
argv
[
i
+
1
]
)
;
i
++
;
i
++
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"-p"
)
&&
!
lastarg
)
{
}
else
if
(
!
strcmp
(
argv
[
i
],
"-p"
)
&&
!
lastarg
)
{
config
.
hostport
=
atoi
(
argv
[
i
+
1
]);
config
.
hostport
=
atoi
(
argv
[
i
+
1
]);
i
++
;
i
++
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"-s"
)
&&
!
lastarg
)
{
}
else
if
(
!
strcmp
(
argv
[
i
],
"-s"
)
&&
!
lastarg
)
{
config
.
hostsocket
=
argv
[
i
+
1
];
config
.
hostsocket
=
strdup
(
argv
[
i
+
1
]
)
;
i
++
;
i
++
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"-d"
)
&&
!
lastarg
)
{
}
else
if
(
!
strcmp
(
argv
[
i
],
"-d"
)
&&
!
lastarg
)
{
config
.
datasize
=
atoi
(
argv
[
i
+
1
]);
config
.
datasize
=
atoi
(
argv
[
i
+
1
]);
...
@@ -409,7 +409,7 @@ int showThroughput(struct aeEventLoop *eventLoop, long long id, void *clientData
...
@@ -409,7 +409,7 @@ int showThroughput(struct aeEventLoop *eventLoop, long long id, void *clientData
return
250
;
/* every 250ms */
return
250
;
/* every 250ms */
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
const
char
**
argv
)
{
int
i
;
int
i
;
client
c
;
client
c
;
...
...
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