Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbf3b8d8

Browse files
committed
Allow \timing in psql to have a better resolution than ~15ms on Windows.
ITAGAKI Takahiro
1 parent5b464e1 commitbf3b8d8

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

‎src/bin/psql/common.h

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.54 2007/01/05 22:19:49 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.55 2007/04/13 20:40:59 mha Exp $
77
*/
88
#ifndefCOMMON_H
99
#defineCOMMON_H
@@ -63,10 +63,6 @@ extern const char *session_username(void);
6363

6464
externchar*expand_tilde(char**filename);
6565

66-
/* Workarounds for Windows */
67-
/* Probably to be moved up the source tree in the future, perhaps to be replaced by
68-
* more specific checks like configure-style HAVE_GETTIMEOFDAY macros.
69-
*/
7066
#ifndefWIN32
7167

7268
#include<sys/time.h>
@@ -78,16 +74,25 @@ typedef struct timeval TimevalStruct;
7874
((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0 + \
7975
((int) ((T)->tv_usec - (U)->tv_usec))) / 1000.0)
8076
#else
77+
/*
78+
* To get good resolution (better than ~15ms) on Windows, use
79+
* the high resolution performance counters. They can't be used
80+
* to get absolute times, but are good for measuring differences.
81+
*/
82+
static __inline__double
83+
GetTimerFrequency(void)
84+
{
85+
LARGE_INTEGERf;
8186

82-
#include<sys/types.h>
83-
#include<sys/timeb.h>
87+
QueryPerformanceFrequency(&f);
88+
return (double)f.QuadPart;
89+
}
8490

85-
typedefstruct_timebTimevalStruct;
91+
typedefLARGE_INTEGERTimevalStruct;
8692

87-
#defineGETTIMEOFDAY(T)_ftime(T)
93+
#defineGETTIMEOFDAY(T)QueryPerformanceCounter((T))
8894
#defineDIFF_MSEC(T,U) \
89-
(((T)->time - (U)->time) * 1000.0 + \
90-
((T)->millitm - (U)->millitm))
91-
#endif
95+
(((T)->QuadPart - (U)->QuadPart) * 1000.0 / GetTimerFrequency())
96+
#endif/* WIN32 */
9297

9398
#endif/* COMMON_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp