+
+ return i;
+
+invalid:
+ printf("Invalid option \"%s\" or option argument missing\n\n",argv[i]);
+
+usage:
+ printf(
+"Usage: redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests]> [-k <boolean>]\n\n"
+" -h <hostname> Server hostname (default 127.0.0.1)\n"
+" -p <port> Server port (default 6379)\n"
+" -s <socket> Server socket (overrides host and port)\n"
+" -c <clients> Number of parallel connections (default 50)\n"
+" -n <requests> Total number of requests (default 10000)\n"
+" -d <size> Data size of SET/GET value in bytes (default 2)\n"
+" -k <boolean> 1=keep alive 0=reconnect (default 1)\n"
+" -r <keyspacelen> Use random keys for SET/GET/INCR, random values for SADD\n"
+" Using this option the benchmark will get/set keys\n"
+" in the form mykey_rand000000012456 instead of constant\n"
+" keys, the <keyspacelen> argument determines the max\n"
+" number of values for the random number. For instance\n"
+" if set to 10 only rand000000000000 - rand000000000009\n"
+" range will be allowed.\n"
+" -q Quiet. Just show query/sec values\n"
+" --csv Output in CSV format\n"
+" -l Loop. Run the tests forever\n"
+" -t <tests> Only run the comma separated list of tests. The test\n"
+" names are the same as the ones produced as output.\n"
+" -I Idle mode. Just open N idle connections and wait.\n\n"
+"Examples:\n\n"
+" Run the benchmark with the default configuration against 127.0.0.1:6379:\n"
+" $ redis-benchmark\n\n"
+" Use 20 parallel clients, for a total of 100k requests, against 192.168.1.1:\n"
+" $ redis-benchmark -h 192.168.1.1 -p 6379 -n 100000 -c 20\n\n"
+" Fill 127.0.0.1:6379 with about 1 million keys only using the SET test:\n"
+" $ redis-benchmark -t set -n 1000000 -r 100000000\n\n"
+" Benchmark 127.0.0.1:6379 for a few commands producing CSV output:\n"
+" $ redis-benchmark -t ping,set,get -n 100000 --csv\n\n"
+ );
+ exit(exit_status);
+}
+
+int showThroughput(struct aeEventLoop *eventLoop, long long id, void *clientData) {
+ REDIS_NOTUSED(eventLoop);
+ REDIS_NOTUSED(id);
+ REDIS_NOTUSED(clientData);
+
+ if (config.csv) return 250;
+ float dt = (float)(mstime()-config.start)/1000.0;
+ float rps = (float)config.requests_finished/dt;
+ printf("%s: %.2f\r", config.title, rps);
+ fflush(stdout);
+ return 250; /* every 250ms */