Fix pgbench's calculation of average latency, when -T is not used.
authorHeikki Linnakangas <[email protected]>
Wed, 21 Sep 2016 10:14:48 +0000 (13:14 +0300)
committerHeikki Linnakangas <[email protected]>
Wed, 21 Sep 2016 10:14:48 +0000 (13:14 +0300)
If the test duration was given in # of transactions (-t or no option),
rather as a duration (-T), the latency average was always printed as 0.
It has been broken ever since the display of latency average was added,
in 9.4.

Fabien Coelho

Discussion: <alpine.DEB.2.20.1607131015370.7486@sto>

src/bin/pgbench/pgbench.c

index 4676a59020a33a35a9a9e2436fd29853241bf723..9033ff2caaef7e4bcc412e63200be55fc3da76b8 100644 (file)
@@ -3296,9 +3296,11 @@ printResults(TState *threads, StatsData *total, instr_time total_time,
        if (throttle_delay || progress || latency_limit)
                printSimpleStats("latency", &total->latency);
        else
-               /* only an average latency computed from the duration is available */
+       {
+               /* no measurement, show average latency computed from run time */
                printf("latency average: %.3f ms\n",
-                          1000.0 * duration * nclients / total->cnt);
+                          1000.0 * time_include * nclients / total->cnt);
+       }
 
        if (throttle_delay)
        {