25#define NUM_DIRECT 10000
42main(
int argc,
char *argv[])
77 if (
strcmp(argv[1],
"--help") == 0 ||
strcmp(argv[1],
"-?") == 0)
82 if (
strcmp(argv[1],
"--version") == 0 ||
strcmp(argv[1],
"-V") == 0)
98 if (endptr ==
optarg || *endptr !=
'\0' ||
120 if (endptr ==
optarg || *endptr !=
'\0' ||
errno != 0)
147 _(
"%s: too many command-line arguments (first is \"%s\")\n"),
155 "Testing timing overhead for %u seconds.\n\n",
183#if PG_INSTR_TSC_CLOCK
208 if (info->frequency_source[0] !=
'\0')
209 printf(
_(
"TSC frequency source: %s\n"), info->frequency_source);
210 printf(
_(
"TSC frequency in use: %d kHz\n"), info->frequency_khz);
212 if (info->calibrated_frequency_khz > 0)
216 printf(
_(
"TSC frequency from calibration: %d kHz\n"), info->calibrated_frequency_khz);
218 diff_pct =
fabs((
double) info->calibrated_frequency_khz - info->frequency_khz) /
219 info->frequency_khz * 100.0;
223 printf(
_(
"WARNING: Calibrated TSC frequency differs by %.1f%% from the TSC frequency in use\n"),
230 printf(
_(
"TSC calibration did not converge\n"));
240 printf(
_(
"\nTSC clock source will be used by default, unless timing_clock_source is set to 'system'.\n"));
242 printf(
_(
"\nTSC clock source will not be used by default, unless timing_clock_source is set to 'tsc'.\n"));
245 printf(
_(
"\nTSC clock source is not usable. Likely unable to determine TSC frequency. Are you running in an unsupported virtualized environment?\n"));
264#if PG_INSTR_TSC_CLOCK
351 printf(
_(
"Average loop time including overhead: %0.2f ns\n"),
363 const char *
header2 =
_(
"% of total");
364 const char *
header3 =
_(
"running %");
384 len1 =
Max(19, len1);
385 len2 =
Max(10, len2);
389 printf(
_(
"Histogram of timing durations:\n"));
390 printf(
"%*s %*s %*s %*s\n",
402 printf(
"%*llu %*.4f %*.4f %*lld\n",
403 len1, (1ULL <<
i) - 1,
410 printf(
"%*s %*s %*s %*s\n",
435 printf(
"%*d %*.4f %*.4f %*lld\n",
451 printf(
"%*lld %*.4f %*.4f %*lld\n",
#define ngettext(s, p, n)
#define Assert(condition)
#define PG_TEXTDOMAIN(domain)
void set_pglocale_pgservice(const char *argv0, const char *app)
#define fprintf(file, fmt, msg)
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
#define required_argument
void pg_initialize_timing(void)
bool pg_set_timing_clock_source(TimingClockSourceType source)
#define PG_INSTR_SYSTEM_CLOCK_NAME
#define INSTR_TIME_SET_CURRENT(t)
#define INSTR_TIME_GT(x, y)
#define INSTR_TIME_GET_NANOSEC(t)
#define INSTR_TIME_GET_DOUBLE(t)
#define INSTR_TIME_SET_CURRENT_FAST(t)
#define INSTR_TIME_SUBTRACT(x, y)
#define INSTR_TIME_ADD_NANOSEC(t, n)
static TimingClockSourceType pg_current_timing_clock_source(void)
@ TIMING_CLOCK_SOURCE_SYSTEM
@ TIMING_CLOCK_SOURCE_AUTO
static int pg_leftmost_one_pos64(uint64 word)
PGDLLIMPORT char * optarg
static rewind_source * source
static void test_system_timing(void)
static void handle_args(int argc, char *argv[])
static long long int largest_diff_count
static uint64 test_timing(unsigned int duration, TimingClockSourceType source, bool fast_timing)
static long long int histogram[64]
static const char * progname
static int64 largest_diff
static unsigned int test_duration
static long long int direct_histogram[NUM_DIRECT]
const char * get_progname(const char *argv0)