1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

pgbench progress with timestamp

This patch adds an option to replace the "time since pgbench run
started" with a Unix epoch timestamp in the progress report so that,
for instance, it is easier to compare timelines with pgsql log

Fabien COELHO <coelho@cri.ensmp.fr>
This commit is contained in:
Teodor Sigaev
2015-09-16 17:24:53 +03:00
parent 5878a377ba
commit 1def9063ca
2 changed files with 30 additions and 3 deletions

View File

@ -428,6 +428,19 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>--progress-timestamp</option></term>
<listitem>
<para>
When showing progress (option <option>-P</>), use a timestamp
(Unix epoch) instead of the number of seconds since the
beginning of the run. The unit is in seconds, with millisecond
precision after the dot.
This helps compare logs generated by various tools.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>-r</option></term> <term><option>-r</option></term>
<term><option>--report-latencies</option></term> <term><option>--report-latencies</option></term>

View File

@ -165,6 +165,7 @@ bool use_quiet; /* quiet logging onto stderr */
int agg_interval; /* log aggregates instead of individual int agg_interval; /* log aggregates instead of individual
* transactions */ * transactions */
int progress = 0; /* thread progress report every this seconds */ int progress = 0; /* thread progress report every this seconds */
bool progress_timestamp = false; /* progress report with Unix time */
int progress_nclients = 0; /* number of clients for progress int progress_nclients = 0; /* number of clients for progress
* report */ * report */
int progress_nthreads = 0; /* number of threads for progress int progress_nthreads = 0; /* number of threads for progress
@ -388,6 +389,7 @@ usage(void)
" -v, --vacuum-all vacuum all four standard tables before tests\n" " -v, --vacuum-all vacuum all four standard tables before tests\n"
" --aggregate-interval=NUM aggregate data over NUM seconds\n" " --aggregate-interval=NUM aggregate data over NUM seconds\n"
" --sampling-rate=NUM fraction of transactions to log (e.g. 0.01 for 1%%)\n" " --sampling-rate=NUM fraction of transactions to log (e.g. 0.01 for 1%%)\n"
" --progress-timestamp use Unix epoch timestamps for progress\n"
"\nCommon options:\n" "\nCommon options:\n"
" -d, --debug print debugging output\n" " -d, --debug print debugging output\n"
" -h, --host=HOSTNAME database server host or socket directory\n" " -h, --host=HOSTNAME database server host or socket directory\n"
@ -2773,6 +2775,7 @@ main(int argc, char **argv)
{"aggregate-interval", required_argument, NULL, 5}, {"aggregate-interval", required_argument, NULL, 5},
{"rate", required_argument, NULL, 'R'}, {"rate", required_argument, NULL, 'R'},
{"latency-limit", required_argument, NULL, 'L'}, {"latency-limit", required_argument, NULL, 'L'},
{"progress-timestamp", no_argument, NULL, 6},
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
@ -3109,6 +3112,10 @@ main(int argc, char **argv)
} }
#endif #endif
break; break;
case 6:
progress_timestamp = true;
benchmarking_option_set = true;
break;
default: default:
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1); exit(1);
@ -3747,6 +3754,7 @@ threadRun(void *arg)
sqlat, sqlat,
lag, lag,
stdev; stdev;
char tbuf[64];
/* /*
* Add up the statistics of all threads. * Add up the statistics of all threads.
@ -3779,10 +3787,16 @@ threadRun(void *arg)
stdev = 0.001 * sqrt(sqlat - 1000000.0 * latency * latency); stdev = 0.001 * sqrt(sqlat - 1000000.0 * latency * latency);
lag = 0.001 * (lags - last_lags) / (count - last_count); lag = 0.001 * (lags - last_lags) / (count - last_count);
if (progress_timestamp)
sprintf(tbuf, "%.03f s",
INSTR_TIME_GET_MILLISEC(now_time) / 1000.0);
else
sprintf(tbuf, "%.1f s", total_run);
fprintf(stderr, fprintf(stderr,
"progress: %.1f s, %.1f tps, " "progress: %s, %.1f tps, lat %.3f ms stddev %.3f",
"lat %.3f ms stddev %.3f", tbuf, tps, latency, stdev);
total_run, tps, latency, stdev);
if (throttle_delay) if (throttle_delay)
{ {
fprintf(stderr, ", lag %.3f ms", lag); fprintf(stderr, ", lag %.3f ms", lag);