diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-03-20 22:27:52 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-03-20 22:27:52 +0000 |
commit | 9e0dd8459658c93ffb6f6bad9bbdd7122e551d51 (patch) | |
tree | fab05f7eec3c3df8589489004b178f20b252675b /src/backend/commands/explain.c | |
parent | 354049c709c9d7d0918272e10e4f30d7f8f38788 (diff) | |
download | postgresql-9e0dd8459658c93ffb6f6bad9bbdd7122e551d51.tar.gz postgresql-9e0dd8459658c93ffb6f6bad9bbdd7122e551d51.zip |
On Windows, use QueryPerformanceCounter instead of gettimeofday for
EXPLAIN ANALYZE instrumentation. Magnus Hagander
Diffstat (limited to 'src/backend/commands/explain.c')
-rw-r--r-- | src/backend/commands/explain.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 7a290e88363..02c9534cab8 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.129 2004/12/31 21:59:41 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.130 2005/03/20 22:27:51 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,7 @@ typedef struct ExplainState static void ExplainOneQuery(Query *query, ExplainStmt *stmt, TupOutputState *tstate); -static double elapsed_time(struct timeval * starttime); +static double elapsed_time(instr_time * starttime); static void explain_outNode(StringInfo str, Plan *plan, PlanState *planstate, Plan *outer_plan, @@ -212,12 +212,12 @@ void ExplainOnePlan(QueryDesc *queryDesc, ExplainStmt *stmt, TupOutputState *tstate) { - struct timeval starttime; + instr_time starttime; double totaltime = 0; ExplainState *es; StringInfo str; - gettimeofday(&starttime, NULL); + INSTR_TIME_SET_CURRENT(starttime); /* If analyzing, we need to cope with queued triggers */ if (stmt->analyze) @@ -275,7 +275,7 @@ ExplainOnePlan(QueryDesc *queryDesc, ExplainStmt *stmt, * Close down the query and free resources; also run any queued * AFTER triggers. Include time for this in the total runtime. */ - gettimeofday(&starttime, NULL); + INSTR_TIME_SET_CURRENT(starttime); ExecutorEnd(queryDesc); @@ -303,14 +303,15 @@ ExplainOnePlan(QueryDesc *queryDesc, ExplainStmt *stmt, pfree(es); } -/* Compute elapsed time in seconds since given gettimeofday() timestamp */ +/* Compute elapsed time in seconds since given timestamp */ static double -elapsed_time(struct timeval * starttime) +elapsed_time(instr_time * starttime) { - struct timeval endtime; + instr_time endtime; - gettimeofday(&endtime, NULL); + INSTR_TIME_SET_CURRENT(endtime); +#ifndef WIN32 endtime.tv_sec -= starttime->tv_sec; endtime.tv_usec -= starttime->tv_usec; while (endtime.tv_usec < 0) @@ -318,8 +319,11 @@ elapsed_time(struct timeval * starttime) endtime.tv_usec += 1000000; endtime.tv_sec--; } - return (double) endtime.tv_sec + - (double) endtime.tv_usec / 1000000.0; +#else /* WIN32 */ + endtime.QuadPart -= starttime->QuadPart; +#endif + + return INSTR_TIME_GET_DOUBLE(endtime); } /* |