diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2016-03-29 14:13:51 -0300 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2016-03-29 14:47:10 -0300 |
commit | a1c935d3b71e44ba36530d47c3ccab6cc9b9eafe (patch) | |
tree | e5e8aa9c61c10d699ae4b7dee1107fba261e27bd /src | |
parent | ad9566470b1ba63167d1dc7ae2cb52d88a448f76 (diff) |
pgbench: allow a script weight of zero
This refines the previous weight range and allows a script to be "turned
off" by passing a zero weight, which is useful when scripting multiple
pgbench runs.
I did not apply the suggested warning when a script uses zero weight; we
use the principle elsewhere that if there's nothing to be done, do
nothing quietly.
Adjust docs accordingly.
Author: Jeff Janes, Fabien Coelho
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pgbench/pgbench.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index 90e538cedc9..52d12239106 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -3054,10 +3054,10 @@ parseScriptWeight(const char *option, char **script) fprintf(stderr, "invalid weight specification: %s\n", sep); exit(1); } - if (wtmp > INT_MAX || wtmp <= 0) + if (wtmp > INT_MAX || wtmp < 0) { fprintf(stderr, - "weight specification out of range (1 .. %u): " INT64_FORMAT "\n", + "weight specification out of range (0 .. %u): " INT64_FORMAT "\n", INT_MAX, (int64) wtmp); exit(1); } @@ -3181,10 +3181,11 @@ printResults(TState *threads, StatsData *total, instr_time total_time, { if (num_scripts > 1) printf("SQL script %d: %s\n" - " - weight = %d\n" + " - weight = %d (targets %.1f%% of total)\n" " - " INT64_FORMAT " transactions (%.1f%% of total, tps = %f)\n", i + 1, sql_script[i].desc, sql_script[i].weight, + 100.0 * sql_script[i].weight / total_weight, sql_script[i].stats.cnt, 100.0 * sql_script[i].stats.cnt / total->cnt, sql_script[i].stats.cnt / time_include); @@ -3628,6 +3629,12 @@ main(int argc, char **argv) /* cannot overflow: weight is 32b, total_weight 64b */ total_weight += sql_script[i].weight; + if (total_weight == 0 && !is_init_mode) + { + fprintf(stderr, "total script weight must not be zero\n"); + exit(1); + } + /* show per script stats if several scripts are used */ if (num_scripts > 1) per_script_stats = true; |