summaryrefslogtreecommitdiff
path: root/src/include/portability
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-05-15 00:17:41 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-05-15 00:17:41 +0000
commit93c701edc6c6f065cd25f77f63ab31aff085d6ac (patch)
tree7eaa06d9c2b64ec7f5647bcf3851281180c783e1 /src/include/portability
parent3bc25384d7a698f25e418bdc5aa7cdd038477d9c (diff)
downloadpostgresql-93c701edc6c6f065cd25f77f63ab31aff085d6ac.tar.gz
Add support for tracking call counts and elapsed runtime for user-defined
functions. Note that because this patch changes FmgrInfo, any external C functions you might be testing with 8.4 will need to be recompiled. Patch by Martin Pihlak, some editorialization by me (principally, removing tracking of getrusage() numbers)
Diffstat (limited to 'src/include/portability')
-rw-r--r--src/include/portability/instr_time.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/include/portability/instr_time.h b/src/include/portability/instr_time.h
index 666d495f20..7f4a0923b6 100644
--- a/src/include/portability/instr_time.h
+++ b/src/include/portability/instr_time.h
@@ -20,6 +20,8 @@
*
* INSTR_TIME_SET_CURRENT(t) set t to current time
*
+ * INSTR_TIME_ADD(x, y) x += y
+ *
* INSTR_TIME_SUBTRACT(x, y) x -= y
*
* INSTR_TIME_ACCUM_DIFF(x, y, z) x += (y - z)
@@ -35,15 +37,15 @@
* only useful on intervals.
*
* When summing multiple measurements, it's recommended to leave the
- * running sum in instr_time form (ie, use INSTR_TIME_ACCUM_DIFF) and
- * convert to a result format only at the end.
+ * running sum in instr_time form (ie, use INSTR_TIME_ADD or
+ * INSTR_TIME_ACCUM_DIFF) and convert to a result format only at the end.
*
* Beware of multiple evaluations of the macro arguments.
*
*
* Copyright (c) 2001-2008, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/include/portability/instr_time.h,v 1.1 2008/05/14 19:10:29 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/portability/instr_time.h,v 1.2 2008/05/15 00:17:41 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -62,6 +64,18 @@ typedef struct timeval instr_time;
#define INSTR_TIME_SET_CURRENT(t) gettimeofday(&(t), NULL)
+#define INSTR_TIME_ADD(x,y) \
+ do { \
+ (x).tv_sec += (y).tv_sec; \
+ (x).tv_usec += (y).tv_usec; \
+ /* Normalize */ \
+ while ((x).tv_usec >= 1000000) \
+ { \
+ (x).tv_usec -= 1000000; \
+ (x).tv_sec++; \
+ } \
+ } while (0)
+
#define INSTR_TIME_SUBTRACT(x,y) \
do { \
(x).tv_sec -= (y).tv_sec; \
@@ -110,6 +124,9 @@ typedef LARGE_INTEGER instr_time;
#define INSTR_TIME_SET_CURRENT(t) QueryPerformanceCounter(&(t))
+#define INSTR_TIME_ADD(x,y) \
+ ((x).QuadPart += (y).QuadPart)
+
#define INSTR_TIME_SUBTRACT(x,y) \
((x).QuadPart -= (y).QuadPart)