summaryrefslogtreecommitdiff
path: root/src/redis-benchmark.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/redis-benchmark.c')
-rw-r--r--src/redis-benchmark.c71
1 files changed, 41 insertions, 30 deletions
diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c
index 0d10e8d3f..2eb689e9f 100644
--- a/src/redis-benchmark.c
+++ b/src/redis-benchmark.c
@@ -192,7 +192,7 @@ static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask);
static void createMissingClients(client c);
static benchmarkThread *createBenchmarkThread(int index);
static void freeBenchmarkThread(benchmarkThread *thread);
-static void freeBenchmarkThreads();
+static void freeBenchmarkThreads(void);
static void *execBenchmarkThread(void *ptr);
static clusterNode *createClusterNode(char *ip, int port);
static redisConfig *getRedisConfig(const char *ip, int port,
@@ -201,7 +201,7 @@ static redisContext *getRedisContext(const char *ip, int port,
const char *hostsocket);
static void freeRedisConfig(redisConfig *cfg);
static int fetchClusterSlotsConfiguration(client c);
-static void updateClusterSlotsConfiguration();
+static void updateClusterSlotsConfiguration(void);
int showThroughput(struct aeEventLoop *eventLoop, long long id,
void *clientData);
@@ -958,7 +958,7 @@ static void showLatencyReport(void) {
}
}
-static void initBenchmarkThreads() {
+static void initBenchmarkThreads(void) {
int i;
if (config.threads) freeBenchmarkThreads();
config.threads = zmalloc(config.num_threads * sizeof(benchmarkThread*));
@@ -968,7 +968,7 @@ static void initBenchmarkThreads() {
}
}
-static void startBenchmarkThreads() {
+static void startBenchmarkThreads(void) {
int i;
for (i = 0; i < config.num_threads; i++) {
benchmarkThread *t = config.threads[i];
@@ -1035,7 +1035,7 @@ static void freeBenchmarkThread(benchmarkThread *thread) {
zfree(thread);
}
-static void freeBenchmarkThreads() {
+static void freeBenchmarkThreads(void) {
int i = 0;
for (; i < config.num_threads; i++) {
benchmarkThread *thread = config.threads[i];
@@ -1096,7 +1096,7 @@ static void freeClusterNode(clusterNode *node) {
zfree(node);
}
-static void freeClusterNodes() {
+static void freeClusterNodes(void) {
int i = 0;
for (; i < config.cluster_node_count; i++) {
clusterNode *n = config.cluster_nodes[i];
@@ -1118,7 +1118,7 @@ static clusterNode **addClusterNode(clusterNode *node) {
/* TODO: This should be refactored to use CLUSTER SLOTS, the migrating/importing
* information is anyway not used.
*/
-static int fetchClusterConfiguration() {
+static int fetchClusterConfiguration(void) {
int success = 1;
redisContext *ctx = NULL;
redisReply *reply = NULL;
@@ -1377,7 +1377,7 @@ cleanup:
}
/* Atomically update the new slots configuration. */
-static void updateClusterSlotsConfiguration() {
+static void updateClusterSlotsConfiguration(void) {
pthread_mutex_lock(&config.is_updating_slots_mutex);
atomicSet(config.is_updating_slots, 1);
int i;
@@ -1414,6 +1414,7 @@ int parseOptions(int argc, char **argv) {
int i;
int lastarg;
int exit_status = 1;
+ char *tls_usage;
for (i = 1; i < argc; i++) {
lastarg = (i == (argc-1));
@@ -1495,6 +1496,11 @@ int parseOptions(int argc, char **argv) {
fprintf(stderr,
"WARNING: -e option has no effect. "
"We now immediately exit on error to avoid false results.\n");
+ } else if (!strcmp(argv[i],"--seed")) {
+ if (lastarg) goto invalid;
+ int rand_seed = atoi(argv[++i]);
+ srandom(rand_seed);
+ init_genrand64(rand_seed);
} else if (!strcmp(argv[i],"-t")) {
if (lastarg) goto invalid;
/* We get the list of tests to run as a string in the form
@@ -1575,8 +1581,31 @@ invalid:
printf("Invalid option \"%s\" or option argument missing\n\n",argv[i]);
usage:
+ tls_usage =
+#ifdef USE_OPENSSL
+" --tls Establish a secure TLS connection.\n"
+" --sni <host> Server name indication for TLS.\n"
+" --cacert <file> CA Certificate file to verify with.\n"
+" --cacertdir <dir> Directory where trusted CA certificates are stored.\n"
+" If neither cacert nor cacertdir are specified, the default\n"
+" system-wide trusted root certs configuration will apply.\n"
+" --insecure Allow insecure TLS connection by skipping cert validation.\n"
+" --cert <file> Client certificate to authenticate with.\n"
+" --key <file> Private key file to authenticate with.\n"
+" --tls-ciphers <list> Sets the list of preferred ciphers (TLSv1.2 and below)\n"
+" in order of preference from highest to lowest separated by colon (\":\").\n"
+" See the ciphers(1ssl) manpage for more information about the syntax of this string.\n"
+#ifdef TLS1_3_VERSION
+" --tls-ciphersuites <list> Sets the list of preferred ciphersuites (TLSv1.3)\n"
+" in order of preference from highest to lowest separated by colon (\":\").\n"
+" See the ciphers(1ssl) manpage for more information about the syntax of this string,\n"
+" and specifically for TLSv1.3 ciphersuites.\n"
+#endif
+#endif
+"";
+
printf(
-"%s%s", /* Split to avoid strings longer than 4095 (-Woverlength-strings). */
+"%s%s%s", /* Split to avoid strings longer than 4095 (-Woverlength-strings). */
"Usage: redis-benchmark [OPTIONS] [COMMAND ARGS...]\n\n"
"Options:\n"
" -h <hostname> Server hostname (default 127.0.0.1)\n"
@@ -1618,28 +1647,10 @@ usage:
" on the command line.\n"
" -I Idle mode. Just open N idle connections and wait.\n"
" -x Read last argument from STDIN.\n"
-#ifdef USE_OPENSSL
-" --tls Establish a secure TLS connection.\n"
-" --sni <host> Server name indication for TLS.\n"
-" --cacert <file> CA Certificate file to verify with.\n"
-" --cacertdir <dir> Directory where trusted CA certificates are stored.\n"
-" If neither cacert nor cacertdir are specified, the default\n"
-" system-wide trusted root certs configuration will apply.\n"
-" --insecure Allow insecure TLS connection by skipping cert validation.\n"
-" --cert <file> Client certificate to authenticate with.\n"
-" --key <file> Private key file to authenticate with.\n"
-" --tls-ciphers <list> Sets the list of preferred ciphers (TLSv1.2 and below)\n"
-" in order of preference from highest to lowest separated by colon (\":\").\n"
-" See the ciphers(1ssl) manpage for more information about the syntax of this string.\n"
-#ifdef TLS1_3_VERSION
-" --tls-ciphersuites <list> Sets the list of preferred ciphersuites (TLSv1.3)\n"
-" in order of preference from highest to lowest separated by colon (\":\").\n"
-" See the ciphers(1ssl) manpage for more information about the syntax of this string,\n"
-" and specifically for TLSv1.3 ciphersuites.\n"
-#endif
-#endif
+" --seed <num> Set the seed for random number generator. Default seed is based on time.\n",
+tls_usage,
" --help Output this help and exit.\n"
-" --version Output version and exit.\n\n",
+" --version Output version and exit.\n\n"
"Examples:\n\n"
" Run the benchmark with the default configuration against 127.0.0.1:6379:\n"
" $ redis-benchmark\n\n"