diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-05-14 19:10:29 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-05-14 19:10:29 +0000 |
| commit | 3bc25384d7a698f25e418bdc5aa7cdd038477d9c (patch) | |
| tree | 0d17e084e418a335ec4eb48470bf7847a9102a6e /src/backend | |
| parent | 719a115874226f6e294a7d1d81d7a8ae559768ad (diff) | |
| download | postgresql-3bc25384d7a698f25e418bdc5aa7cdd038477d9c.tar.gz | |
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.
Diffstat (limited to 'src/backend')
| -rw-r--r-- | src/backend/commands/explain.c | 16 | ||||
| -rw-r--r-- | src/backend/executor/instrument.c | 22 |
2 files changed, 4 insertions, 34 deletions
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 6fbdabd1d2..0892cdbe3e 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994-5, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.174 2008/05/12 20:01:59 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.175 2008/05/14 19:10:29 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -390,19 +390,7 @@ elapsed_time(instr_time *starttime) instr_time endtime; INSTR_TIME_SET_CURRENT(endtime); - -#ifndef WIN32 - endtime.tv_sec -= starttime->tv_sec; - endtime.tv_usec -= starttime->tv_usec; - while (endtime.tv_usec < 0) - { - endtime.tv_usec += 1000000; - endtime.tv_sec--; - } -#else /* WIN32 */ - endtime.QuadPart -= starttime->QuadPart; -#endif - + INSTR_TIME_SUBTRACT(endtime, *starttime); return INSTR_TIME_GET_DOUBLE(endtime); } diff --git a/src/backend/executor/instrument.c b/src/backend/executor/instrument.c index fa0a7f7b50..b83d6f5d32 100644 --- a/src/backend/executor/instrument.c +++ b/src/backend/executor/instrument.c @@ -7,7 +7,7 @@ * Copyright (c) 2001-2008, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/instrument.c,v 1.20 2008/01/01 19:45:49 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/executor/instrument.c,v 1.21 2008/05/14 19:10:29 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -55,25 +55,7 @@ InstrStopNode(Instrumentation *instr, double nTuples) } INSTR_TIME_SET_CURRENT(endtime); - -#ifndef WIN32 - instr->counter.tv_sec += endtime.tv_sec - instr->starttime.tv_sec; - instr->counter.tv_usec += endtime.tv_usec - instr->starttime.tv_usec; - - /* Normalize after each add to avoid overflow/underflow of tv_usec */ - while (instr->counter.tv_usec < 0) - { - instr->counter.tv_usec += 1000000; - instr->counter.tv_sec--; - } - while (instr->counter.tv_usec >= 1000000) - { - instr->counter.tv_usec -= 1000000; - instr->counter.tv_sec++; - } -#else /* WIN32 */ - instr->counter.QuadPart += (endtime.QuadPart - instr->starttime.QuadPart); -#endif + INSTR_TIME_ACCUM_DIFF(instr->counter, endtime, instr->starttime); INSTR_TIME_SET_ZERO(instr->starttime); |
