]> granicus.if.org Git - postgresql/blobdiff - src/bin/pgbench/pgbench.c
Fix incorrect tps number calculation in "excluding connections establishing".
[postgresql] / src / bin / pgbench / pgbench.c
index 30e8d2a3f2ec88d9b73c445b725d06c228e3ae5c..f2d435b19804bfb444a1282964e6e23e335f1eaf 100644 (file)
@@ -165,6 +165,7 @@ bool                use_quiet;                      /* quiet logging onto stderr */
 int                    agg_interval;           /* log aggregates instead of individual
                                                                 * transactions */
 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
                                                                                 * report */
 int                    progress_nthreads = 0;          /* number of threads for progress
@@ -373,8 +374,7 @@ usage(void)
                 "  -f, --file=FILENAME      read transaction script from FILENAME\n"
                   "  -j, --jobs=NUM           number of threads (default: 1)\n"
                   "  -l, --log                write transaction times to log file\n"
-       "  -L, --latency-limit=NUM  count transactions lasting more than NUM ms\n"
-                  "                           as late.\n"
+       "  -L, --latency-limit=NUM  count transactions lasting more than NUM ms as late\n"
                   "  -M, --protocol=simple|extended|prepared\n"
                   "                           protocol for submitting queries (default: simple)\n"
                   "  -n, --no-vacuum          do not run VACUUM before tests\n"
@@ -389,6 +389,7 @@ usage(void)
                   "  -v, --vacuum-all         vacuum all four standard tables before tests\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"
+                  "  --progress-timestamp     use Unix epoch timestamps for progress\n"
                   "\nCommon options:\n"
                   "  -d, --debug              print debugging output\n"
          "  -h, --host=HOSTNAME      database server host or socket directory\n"
@@ -2198,7 +2199,7 @@ parseQuery(Command *cmd, const char *raw_sql)
        return true;
 }
 
-void
+void pg_attribute_noreturn()
 syntax_error(const char *source, const int lineno,
                         const char *line, const char *command,
                         const char *msg, const char *more, const int column)
@@ -2615,7 +2616,7 @@ printResults(int ttype, int64 normal_xacts, int nclients,
        time_include = INSTR_TIME_GET_DOUBLE(total_time);
        tps_include = normal_xacts / time_include;
        tps_exclude = normal_xacts / (time_include -
-                                               (INSTR_TIME_GET_DOUBLE(conn_total_time) / nthreads));
+                                               (INSTR_TIME_GET_DOUBLE(conn_total_time) / nclients));
 
        if (ttype == 0)
                s = "TPC-B (sort of)";
@@ -2774,6 +2775,7 @@ main(int argc, char **argv)
                {"aggregate-interval", required_argument, NULL, 5},
                {"rate", required_argument, NULL, 'R'},
                {"latency-limit", required_argument, NULL, 'L'},
+               {"progress-timestamp", no_argument, NULL, 6},
                {NULL, 0, NULL, 0}
        };
 
@@ -3110,6 +3112,10 @@ main(int argc, char **argv)
                                }
 #endif
                                break;
+                       case 6:
+                               progress_timestamp = true;
+                               benchmarking_option_set = true;
+                               break;
                        default:
                                fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
                                exit(1);
@@ -3748,6 +3754,7 @@ threadRun(void *arg)
                                                        sqlat,
                                                        lag,
                                                        stdev;
+                               char            tbuf[64];
 
                                /*
                                 * Add up the statistics of all threads.
@@ -3780,10 +3787,16 @@ threadRun(void *arg)
                                stdev = 0.001 * sqrt(sqlat - 1000000.0 * latency * latency);
                                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,
-                                               "progress: %.1f s, %.1f tps, "
-                                               "lat %.3f ms stddev %.3f",
-                                               total_run, tps, latency, stdev);
+                                               "progress: %s, %.1f tps, lat %.3f ms stddev %.3f",
+                                               tbuf, tps, latency, stdev);
+
                                if (throttle_delay)
                                {
                                        fprintf(stderr, ", lag %.3f ms", lag);