pgbench-init-stats-2.patch
text/x-diff
Filename: pgbench-init-stats-2.patch
Type: text/x-diff
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/bin/pgbench/pgbench.c | 37 | 3 |
| src/bin/pgbench/t/001_pgbench_with_server.pl | 3 | 3 |
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 99529de52a..76a5b87fe8 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -3941,32 +3941,48 @@ checkInitSteps(const char *initialize_steps)
static void
runInitSteps(const char *initialize_steps)
{
- PGconn *con;
- const char *step;
+ PQExpBufferData stats;
+ PGconn *con;
+ const char *step;
+ double run_time = 0.0;
+ bool first = true;
+
+ initPQExpBuffer(&stats);
if ((con = doConnect()) == NULL)
exit(1);
for (step = initialize_steps; *step != '\0'; step++)
{
+ instr_time start;
+ char *op = NULL;
+
+ INSTR_TIME_SET_CURRENT(start);
+
switch (*step)
{
case 'd':
+ op = "drop";
initDropTables(con);
break;
case 't':
+ op = "create table";
initCreateTables(con);
break;
case 'g':
+ op = "generate",
initGenerateData(con);
break;
case 'v':
+ op = "vacuum";
initVacuum(con);
break;
case 'p':
+ op = "primary keys";
initCreatePKeys(con);
break;
case 'f':
+ op = "foreign keys";
initCreateFKeys(con);
break;
case ' ':
@@ -3977,10 +3993,28 @@ runInitSteps(const char *initialize_steps)
PQfinish(con);
exit(1);
}
+
+ if (op != NULL)
+ {
+ instr_time diff;
+ double elapsed_sec;
+
+ INSTR_TIME_SET_CURRENT(diff);
+ INSTR_TIME_SUBTRACT(diff, start);
+ elapsed_sec = INSTR_TIME_GET_DOUBLE(diff);
+
+ if (!first)
+ appendPQExpBufferStr(&stats, ", ");
+
+ first = false;
+ appendPQExpBuffer(&stats, "%s %.2f s", op, elapsed_sec);
+ run_time += elapsed_sec;
+ }
}
- fprintf(stderr, "done.\n");
+ fprintf(stderr, "done in %.2f s (%s).\n", run_time, stats.data);
PQfinish(con);
+ termPQExpBuffer(&stats);
}
/*
diff --git a/src/bin/pgbench/t/001_pgbench_with_server.pl b/src/bin/pgbench/t/001_pgbench_with_server.pl
index 62906d5e55..696dc2b36c 100644
--- a/src/bin/pgbench/t/001_pgbench_with_server.pl
+++ b/src/bin/pgbench/t/001_pgbench_with_server.pl
@@ -101,7 +101,7 @@ pgbench(
[qr{^$}],
[
qr{creating tables}, qr{vacuuming},
- qr{creating primary keys}, qr{done\.}
+ qr{creating primary keys}, qr{done in \d+\.\d\d s }
],
'pgbench scale 1 initialization',);
@@ -116,7 +116,7 @@ pgbench(
qr{vacuuming},
qr{creating primary keys},
qr{creating foreign keys},
- qr{done\.}
+ qr{done in \d+\.\d\d s }
],
'pgbench scale 1 initialization');
@@ -131,7 +131,7 @@ pgbench(
qr{creating primary keys},
qr{.* of .* tuples \(.*\) done},
qr{creating foreign keys},
- qr{done\.}
+ qr{done in \d+\.\d\d s }
],
'pgbench --init-steps');