1 | // ===========================================================================
|
---|
2 | // (C) 1999 Vienna University of Technology
|
---|
3 | // ===========================================================================
|
---|
4 | // NAME: BenchTimer
|
---|
5 | // TYPE: c++ header
|
---|
6 | // PROJECT: Urban Viz/yare (yet another rendering engine)
|
---|
7 | // CONTENT: Very accurate timer for Win32 systems
|
---|
8 | // (uses QueryPerformanceCounter, usually microseconds)
|
---|
9 | // VERSION: 0.1
|
---|
10 | // ===========================================================================
|
---|
11 | // AUTHORS: mw Michael Wimmer
|
---|
12 | // ===========================================================================
|
---|
13 | // HISTORY:
|
---|
14 | //
|
---|
15 | // 15-jul-99 14:00:00 mw created
|
---|
16 | // ===========================================================================
|
---|
17 | // $Header: /usr/local/cvsyare/cvsyare/src/yareutils/BenchTimer.h,v 1.1 2002/09/24 16:53:56 wimmer Exp $
|
---|
18 | // ===========================================================================
|
---|
19 |
|
---|
20 | #ifndef NO_PRAGMA_ONCE
|
---|
21 | #pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #ifndef _BENCHTIMER_H
|
---|
25 | #define _BENCHTIMER_H
|
---|
26 |
|
---|
27 | #ifdef WIN32
|
---|
28 |
|
---|
29 | #if !(_MSC_VER >= 1200)
|
---|
30 | #define __forceinline inline
|
---|
31 | #endif
|
---|
32 |
|
---|
33 | // we definitely want timers to be inlined!
|
---|
34 | #define PERFTIMER_INLINE __forceinline
|
---|
35 |
|
---|
36 | #ifndef WIN32_LEAN_AND_MEAN
|
---|
37 | #define WIN32_LEAN_AND_MEAN
|
---|
38 | #endif
|
---|
39 | #define NOMINMAX
|
---|
40 | #include <windows.h> // for LARGE_INTEGER
|
---|
41 |
|
---|
42 | #define PERFTIMER BenchTimer
|
---|
43 |
|
---|
44 | #define TIMEVAL_T LARGE_INTEGER
|
---|
45 | #define TIMEVAL_ZERO(__timval) (__timval).QuadPart = 0;
|
---|
46 | #define TIMEVAL_GET(__timval) QueryPerformanceCounter(&__timval);
|
---|
47 | #define TIMEVAL_TODOUBLE(__timval) ((double)__timval.QuadPart / (double)frequency.QuadPart)
|
---|
48 | #define TIMEVAL_ASSIGN(__timval1, __timval2) __timval1.QuadPart = __timval2.QuadPart;
|
---|
49 |
|
---|
50 | #define TIMEVAL_ADD(total, end, start) \
|
---|
51 | if (end.QuadPart > start.QuadPart) \
|
---|
52 | total.QuadPart += end.QuadPart - start.QuadPart; \
|
---|
53 | else \
|
---|
54 | total.QuadPart += MAXLONGLONG - end.QuadPart + start.QuadPart;
|
---|
55 |
|
---|
56 | #include "PerfTimerSkeleton.h"
|
---|
57 |
|
---|
58 | #else
|
---|
59 | #define DUMMY_TIMER
|
---|
60 | #include "PerfTimerSkeleton.h"
|
---|
61 | #undef DUMMY_TIMER
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | #undef PERFTIMER
|
---|
65 | #undef TIMEVAL_ZERO
|
---|
66 | //#undef TIMEVAL_GET
|
---|
67 | #undef TIMEVAL_TODOUBLE
|
---|
68 | #undef TIMEVAL_ASSIGN
|
---|
69 | //#undef TIMEVAL_ADD
|
---|
70 |
|
---|
71 | #endif // _BENCHTIMER_H
|
---|