diff options
author | Robert Haas <rhaas@postgresql.org> | 2012-03-30 08:15:25 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2012-03-30 08:17:54 -0400 |
commit | 3f427c1353d92c41069197b31ea6c8b89f24cd11 (patch) | |
tree | 218da86e357b1ced87d9b466e642f0d563b01fa4 /contrib/pg_test_timing/pg_test_timing.c | |
parent | b75fbe91910df323a8d3e1d92a8bb4dd0d5e88a9 (diff) |
pg_test_timing: Lame hack to work around compiler warning.
Fujii Masao, plus a comment by me. While I'm at it, correctly tabify
this chunk of code.
Diffstat (limited to 'contrib/pg_test_timing/pg_test_timing.c')
-rw-r--r-- | contrib/pg_test_timing/pg_test_timing.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/contrib/pg_test_timing/pg_test_timing.c b/contrib/pg_test_timing/pg_test_timing.c index cdfa07f6eb6..4e43694338b 100644 --- a/contrib/pg_test_timing/pg_test_timing.c +++ b/contrib/pg_test_timing/pg_test_timing.c @@ -107,6 +107,7 @@ test_timing(int32 duration) instr_time start_time, end_time, temp; static int64 histogram[32]; + char buf[100]; total_time = duration > 0 ? duration * 1000000 : 0; @@ -150,13 +151,15 @@ test_timing(int32 duration) printf("%9s: %10s %9s\n", "< usec", "count", "percent"); found = 0; - for (i = 31; i >= 0; i--) - { - if (found || histogram[i]) - { - found = 1; - printf("%9ld: %10ld %8.5f%%\n", 1l << i, histogram[i], - (double) histogram[i] * 100 / loop_count); - } - } + for (i = 31; i >= 0; i--) + { + if (found || histogram[i]) + { + found = 1; + /* lame hack to work around INT64_FORMAT deficiencies */ + snprintf(buf, sizeof(buf), INT64_FORMAT, histogram[i]); + printf("%9ld: %10s %8.5f%%\n", 1l << i, buf, + (double) histogram[i] * 100 / loop_count); + } + } } |