From 86802d4f2681baa04869fabfbd0ca6c2fe0a94d7 Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 14 Feb 2019 13:19:45 +0100 Subject: [PATCH] redis-benchmark: default precision=1, integer ms after 2 milliseconds. Reltaed to discussion and PR #5840. --- src/redis-benchmark.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c index 5e6f6a62..31f91eb0 100644 --- a/src/redis-benchmark.c +++ b/src/redis-benchmark.c @@ -458,10 +458,21 @@ static void showLatencyReport(void) { qsort(config.latency,config.requests,sizeof(long long),compareLatency); for (i = 0; i < config.requests; i++) { - if (config.latency[i]/usbetweenlat != curlat || i == (config.requests-1)) { + if (config.latency[i]/usbetweenlat != curlat || + i == (config.requests-1)) + { curlat = config.latency[i]/usbetweenlat; perc = ((float)(i+1)*100)/config.requests; - printf("%.2f%% <= %.*f milliseconds\n", perc, config.precision, curlat/pow(10.0, config.precision)); + printf("%.2f%% <= %.*f milliseconds\n", perc, config.precision, + curlat/pow(10.0, config.precision)); + + /* After the 2 milliseconds latency to have percentages split + * by decimals will just add a lot of noise to the output. */ + if (config.latency[i] > 2000) { + config.precision = 0; + usbetweenlat = ipow(10, + MAX_LATENCY_PRECISION-config.precision); + } } } printf("%.2f requests per second\n\n", reqpersec); @@ -699,7 +710,7 @@ int main(int argc, const char **argv) { config.tests = NULL; config.dbnum = 0; config.auth = NULL; - config.precision = 0; + config.precision = 1; i = parseOptions(argc,argv); argc -= i;