QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches
pctimer.h
Go to the documentation of this file.
1// -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
2// vim:tabstop=4:shiftwidth=4:expandtab:
3
4/*
5 * Copyright (C) 2004-2008 Wu Yongwei <adah at users dot sourceforge dot net>
6 *
7 * This software is provided 'as-is', without any express or implied
8 * warranty. In no event will the authors be held liable for any
9 * damages arising from the use of this software.
10 *
11 * Permission is granted to anyone to use this software for any purpose,
12 * including commercial applications, and to alter it and redistribute
13 * it freely, subject to the following restrictions:
14 *
15 * 1. The origin of this software must not be misrepresented; you must
16 * not claim that you wrote the original software. If you use this
17 * software in a product, an acknowledgement in the product
18 * documentation would be appreciated but is not required.
19 * 2. Altered source versions must be plainly marked as such, and must
20 * not be misrepresented as being the original software.
21 * 3. This notice may not be removed or altered from any source
22 * distribution.
23 *
24 * This file is part of Stones of Nvwa:
25 * http://sourceforge.net/projects/nvwa
26 *
27 */
28
40#ifndef QT_NO_DEBUG
41#ifndef _QX_MODE_RELEASE
42#if _QX_USE_MEM_LEAK_DETECTION
43#ifndef _PCTIMER_H
44
45namespace qx {
46namespace memory {
47
48typedef double pctimer_t;
49
50} // namespace memory
51} // namespace qx
52
53#if defined(_WIN32) || defined(__CYGWIN__)
54
55#ifndef _WIN32
56#define _PCTIMER_NO_WIN32
57#endif /* _WIN32 */
58
59#ifndef WIN32_LEAN_AND_MEAN
60#define WIN32_LEAN_AND_MEAN
61#endif /* WIN32_LEAN_AND_MEAN */
62#include <windows.h>
63
64#ifdef _PCTIMER_NO_WIN32
65#undef _PCTIMER_NO_WIN32
66#undef _WIN32
67#endif /* _PCTIMER_NO_WIN32 */
68
69namespace qx {
70namespace memory {
71
72__inline pctimer_t pctimer(void)
73{
74 static LARGE_INTEGER __pcount, __pcfreq;
75 static int __initflag;
76
77 if (!__initflag)
78 {
79 QueryPerformanceFrequency(&__pcfreq);
80 __initflag++;
81 }
82
83 QueryPerformanceCounter(&__pcount);
84 return (double)__pcount.QuadPart / (double)__pcfreq.QuadPart;
85}
86
87} // namespace memory
88} // namespace qx
89
90#else /* Not Win32/Cygwin */
91
92#include <sys/time.h>
93
94namespace qx {
95namespace memory {
96
97__inline pctimer_t pctimer(void)
98{
99 struct timeval __tv;
100 gettimeofday(&__tv, NULL);
101 return (double)__tv.tv_sec + (double)__tv.tv_usec / 1000000;
102}
103
104} // namespace memory
105} // namespace qx
106
107#endif /* Win32/Cygwin */
108
109#endif /* _PCTIMER_H */
110#endif // _QX_USE_MEM_LEAK_DETECTION
111#endif // _QX_MODE_RELEASE
112#endif // QT_NO_DEBUG
__inline pctimer_t pctimer(void)
Definition pctimer.h:97
double pctimer_t
Definition pctimer.h:48
Root namespace for all QxOrm library features.