From e29ff7fef693e830b4929f9b7444cc943fd16516 Mon Sep 17 00:00:00 2001 From: "Chao Li (Evan)" Date: Thu, 2 Apr 2026 10:29:06 +0800 Subject: [PATCH v1 2/2] pg_test_timing: use int64 for largest observed time delta pg_test_timing obtains timing deltas with INSTR_TIME_GET_NANOSEC(), which returns a nanosecond value that should be stored in int64. Adjust diff and largest_diff to use int64 accordingly. Also fix the corresponding printf format specifiers so these values are printed correctly. Author: Chao Li Reviewed-by: Discussion: https://postgr.es/m/ --- src/bin/pg_test_timing/pg_test_timing.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bin/pg_test_timing/pg_test_timing.c b/src/bin/pg_test_timing/pg_test_timing.c index cbdc5af09d9..07b98a6388d 100644 --- a/src/bin/pg_test_timing/pg_test_timing.c +++ b/src/bin/pg_test_timing/pg_test_timing.c @@ -25,7 +25,7 @@ static long long int histogram[32]; static long long int direct_histogram[NUM_DIRECT]; /* separately record highest observed duration */ -static int32 largest_diff; +static int64 largest_diff; static long long int largest_diff_count; @@ -176,8 +176,8 @@ test_timing(unsigned int duration) while (INSTR_TIME_GT(end_time, cur)) { - int32 diff, - bits; + int64 diff; + int32 bits; instr_time diff_time; prev = cur; @@ -191,7 +191,7 @@ test_timing(unsigned int duration) if (unlikely(diff < 0)) { fprintf(stderr, _("Detected clock going backwards in time.\n")); - fprintf(stderr, _("Time warp: %d ns\n"), diff); + fprintf(stderr, _("Time warp: %lld ns\n"), diff); exit(1); } @@ -319,7 +319,7 @@ output(uint64 loop_count) double prct = (double) largest_diff_count * 100 / loop_count; printf("...\n"); - printf("%*d %*.4f %*.4f %*lld\n", + printf("%*lld %*.4f %*.4f %*lld\n", len1, largest_diff, len2, prct, len3, 100.0, -- 2.50.1 (Apple Git-155)