mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +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:
@ -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 <sys/stat.h> /* 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);
|
||||
|
Reference in New Issue
Block a user