Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1def906

Browse files
committed
pgbench progress with timestamp
This patch adds an option to replace the "time since pgbench runstarted" with a Unix epoch timestamp in the progress report so that,for instance, it is easier to compare timelines with pgsql logFabien COELHO <coelho@cri.ensmp.fr>
1 parent5878a37 commit1def906

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

‎doc/src/sgml/ref/pgbench.sgml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,19 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
428428
</listitem>
429429
</varlistentry>
430430

431+
<varlistentry>
432+
<term><option>--progress-timestamp</option></term>
433+
<listitem>
434+
<para>
435+
When showing progress (option <option>-P</>), use a timestamp
436+
(Unix epoch) instead of the number of seconds since the
437+
beginning of the run. The unit is in seconds, with millisecond
438+
precision after the dot.
439+
This helps compare logs generated by various tools.
440+
</para>
441+
</listitem>
442+
</varlistentry>
443+
431444
<varlistentry>
432445
<term><option>-r</option></term>
433446
<term><option>--report-latencies</option></term>

‎src/bin/pgbench/pgbench.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ booluse_quiet;/* quiet logging onto stderr */
165165
intagg_interval;/* log aggregates instead of individual
166166
* transactions */
167167
intprogress=0;/* thread progress report every this seconds */
168+
boolprogress_timestamp= false;/* progress report with Unix time */
168169
intprogress_nclients=0;/* number of clients for progress
169170
* report */
170171
intprogress_nthreads=0;/* number of threads for progress
@@ -388,6 +389,7 @@ usage(void)
388389
" -v, --vacuum-all vacuum all four standard tables before tests\n"
389390
" --aggregate-interval=NUM aggregate data over NUM seconds\n"
390391
" --sampling-rate=NUM fraction of transactions to log (e.g. 0.01 for 1%%)\n"
392+
" --progress-timestamp use Unix epoch timestamps for progress\n"
391393
"\nCommon options:\n"
392394
" -d, --debug print debugging output\n"
393395
" -h, --host=HOSTNAME database server host or socket directory\n"
@@ -2773,6 +2775,7 @@ main(int argc, char **argv)
27732775
{"aggregate-interval",required_argument,NULL,5},
27742776
{"rate",required_argument,NULL,'R'},
27752777
{"latency-limit",required_argument,NULL,'L'},
2778+
{"progress-timestamp",no_argument,NULL,6},
27762779
{NULL,0,NULL,0}
27772780
};
27782781

@@ -3109,6 +3112,10 @@ main(int argc, char **argv)
31093112
}
31103113
#endif
31113114
break;
3115+
case6:
3116+
progress_timestamp= true;
3117+
benchmarking_option_set= true;
3118+
break;
31123119
default:
31133120
fprintf(stderr,_("Try \"%s --help\" for more information.\n"),progname);
31143121
exit(1);
@@ -3747,6 +3754,7 @@ threadRun(void *arg)
37473754
sqlat,
37483755
lag,
37493756
stdev;
3757+
chartbuf[64];
37503758

37513759
/*
37523760
* Add up the statistics of all threads.
@@ -3779,10 +3787,16 @@ threadRun(void *arg)
37793787
stdev=0.001*sqrt(sqlat-1000000.0*latency*latency);
37803788
lag=0.001* (lags-last_lags) / (count-last_count);
37813789

3790+
if (progress_timestamp)
3791+
sprintf(tbuf,"%.03f s",
3792+
INSTR_TIME_GET_MILLISEC(now_time) /1000.0);
3793+
else
3794+
sprintf(tbuf,"%.1f s",total_run);
3795+
37823796
fprintf(stderr,
3783-
"progress: %.1fs, %.1f tps,"
3784-
"lat %.3f ms stddev %.3f",
3785-
total_run,tps,latency,stdev);
3797+
"progress: %s, %.1f tps,lat %.3f ms stddev %.3f",
3798+
tbuf,tps,latency,stdev);
3799+
37863800
if (throttle_delay)
37873801
{
37883802
fprintf(stderr,", lag %.3f ms",lag);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp