[2015] | 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 |
|
---|
| 37 | #define WIN32_LEAN_AND_MEAN
|
---|
| 38 | #define NOMINMAX
|
---|
| 39 | #include <windows.h> // for LARGE_INTEGER
|
---|
| 40 |
|
---|
| 41 | #define PERFTIMER BenchTimer
|
---|
| 42 |
|
---|
| 43 | #define TIMEVAL_T LARGE_INTEGER
|
---|
| 44 | #define TIMEVAL_ZERO(__timval) (__timval).QuadPart = 0;
|
---|
| 45 | #define TIMEVAL_GET(__timval) QueryPerformanceCounter(&__timval);
|
---|
| 46 | #define TIMEVAL_TODOUBLE(__timval) ((double)__timval.QuadPart / (double)frequency.QuadPart)
|
---|
| 47 | #define TIMEVAL_ASSIGN(__timval1, __timval2) __timval1.QuadPart = __timval2.QuadPart;
|
---|
| 48 |
|
---|
| 49 | #define TIMEVAL_ADD(total, end, start) \
|
---|
| 50 | if (end.QuadPart > start.QuadPart) \
|
---|
| 51 | total.QuadPart += end.QuadPart - start.QuadPart; \
|
---|
| 52 | else \
|
---|
| 53 | total.QuadPart += MAXLONGLONG - end.QuadPart + start.QuadPart;
|
---|
| 54 |
|
---|
| 55 | #include "PerfTimerSkeleton.h"
|
---|
| 56 |
|
---|
| 57 | #else
|
---|
| 58 | #define DUMMY_TIMER
|
---|
| 59 | #include "PerfTimerSkeleton.h"
|
---|
| 60 | #undef DUMMY_TIMER
|
---|
| 61 | #endif
|
---|
| 62 |
|
---|
| 63 | #undef PERFTIMER
|
---|
| 64 | #undef TIMEVAL_ZERO
|
---|
| 65 | //#undef TIMEVAL_GET
|
---|
| 66 | #undef TIMEVAL_TODOUBLE
|
---|
| 67 | #undef TIMEVAL_ASSIGN
|
---|
| 68 | //#undef TIMEVAL_ADD
|
---|
| 69 |
|
---|
| 70 | #endif // _BENCHTIMER_H
|
---|