1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-13 14:22:43 +03:00

Move the "instr_time" typedef and associated macros into a new header

file portability/instr_time.h, and add a couple more macros to eliminate
some abstraction leakage we formerly had.  Also update psql to use this
header instead of its own copy of nearly the same code.

This commit in itself is just code cleanup and shouldn't change anything.
It lays some groundwork for the upcoming function-stats patch, though.
This commit is contained in:
Tom Lane
2008-05-14 19:10:29 +00:00
parent 719a115874
commit 3bc25384d7
8 changed files with 178 additions and 131 deletions

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.56 2008/01/01 19:45:55 momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.57 2008/05/14 19:10:29 tgl Exp $
*/
#ifndef COMMON_H
#define COMMON_H
@@ -63,36 +63,4 @@ extern const char *session_username(void);
extern char *expand_tilde(char **filename);
#ifndef WIN32
#include <sys/time.h>
typedef struct timeval TimevalStruct;
#define GETTIMEOFDAY(T) gettimeofday(T, NULL)
#define DIFF_MSEC(T, U) \
((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0 + \
((int) ((T)->tv_usec - (U)->tv_usec))) / 1000.0)
#else
/*
* To get good resolution (better than ~15ms) on Windows, use
* the high resolution performance counters. They can't be used
* to get absolute times, but are good for measuring differences.
*/
static __inline__ double
GetTimerFrequency(void)
{
LARGE_INTEGER f;
QueryPerformanceFrequency(&f);
return (double) f.QuadPart;
}
typedef LARGE_INTEGER TimevalStruct;
#define GETTIMEOFDAY(T) QueryPerformanceCounter((T))
#define DIFF_MSEC(T, U) \
(((T)->QuadPart - (U)->QuadPart) * 1000.0 / GetTimerFrequency())
#endif /* WIN32 */
#endif /* COMMON_H */