From 3bc25384d7a698f25e418bdc5aa7cdd038477d9c Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 14 May 2008 19:10:29 +0000 Subject: 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. --- src/bin/psql/command.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/bin/psql/command.c') diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index f74ce951409..b86d67e9281 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2008, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.188 2008/05/08 17:04:26 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.189 2008/05/14 19:10:29 tgl Exp $ */ #include "postgres_fe.h" #include "command.h" @@ -30,6 +30,8 @@ #include /* for stat() */ #endif +#include "portability/instr_time.h" + #include "libpq-fe.h" #include "pqexpbuffer.h" #include "dumputils.h" @@ -282,24 +284,22 @@ exec_command(const char *cmd, else if (pg_strcasecmp(cmd, "copy") == 0) { /* Default fetch-it-all-and-print mode */ - TimevalStruct before, + instr_time before, after; - double elapsed_msec = 0; char *opt = psql_scan_slash_option(scan_state, OT_WHOLE_LINE, NULL, false); if (pset.timing) - GETTIMEOFDAY(&before); + INSTR_TIME_SET_CURRENT(before); success = do_copy(opt); if (pset.timing && success) { - GETTIMEOFDAY(&after); - elapsed_msec = DIFF_MSEC(&after, &before); - printf(_("Time: %.3f ms\n"), elapsed_msec); - + INSTR_TIME_SET_CURRENT(after); + INSTR_TIME_SUBTRACT(after, before); + printf(_("Time: %.3f ms\n"), INSTR_TIME_GET_MILLISEC(after)); } free(opt); -- cgit v1.2.3