mirror of
https://github.com/fluencelabs/redis
synced 2025-03-30 22:31:03 +00:00
csv output for redis-benchmark
This commit is contained in:
parent
410dfe90b2
commit
7b86f5e6d5
@ -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) {
|
|||||||
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) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
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) {
|
|||||||
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:
|
|||||||
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
|
|||||||
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) {
|
|||||||
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) {
|
|||||||
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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user