summaryrefslogtreecommitdiff
path: root/shared/perf.h
diff options
context:
space:
mode:
Diffstat (limited to 'shared/perf.h')
-rw-r--r--shared/perf.h30
1 files changed, 20 insertions, 10 deletions
diff --git a/shared/perf.h b/shared/perf.h
index 62473259..e4e279bb 100644
--- a/shared/perf.h
+++ b/shared/perf.h
@@ -4,13 +4,23 @@
// * Copyright (C) 2008-2010 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
//
-#include <windows.h>
+#ifndef DEBUG_PERF_HEADER
+#define DEBUG_PERF_HEADER
+
+//#define WIN32_LEAN_AND_MEAN -> not in a header
+#include <wx/msw/wrapwin.h> //includes "windows.h"
#include <sstream>
+#ifdef __MINGW32__
+ #define DEPRECATED(x) x __attribute__ ((deprecated))
+#elif defined _MSC_VER
+ #define DEPRECATED(x) __declspec(deprecated) x
+#endif
+
class Performance
{
public:
- Performance() : resultWasShown(false), startTime(::GetTickCount()) {}
+ DEPRECATED(Performance()) : resultWasShown(false), startTime(::GetTickCount()) {}
~Performance()
{
@@ -20,18 +30,16 @@ public:
void showResult()
{
- resultWasShown = true;
-
- const DWORD currentTime = ::GetTickCount();
- const DWORD delta = currentTime - startTime;
- startTime = currentTime;
-
+ const DWORD delta = ::GetTickCount() - startTime;
std::ostringstream ss;
ss << delta << " ms";
-
+
::MessageBoxA(NULL, ss.str().c_str(), "Timer", 0);
- }
+ resultWasShown = true;
+ startTime = ::GetTickCount(); //don't include call to MessageBox()!
+ }
+
private:
bool resultWasShown;
DWORD startTime;
@@ -40,3 +48,5 @@ private:
//two macros for quick performance measurements
#define PERF_START Performance a;
#define PERF_STOP a.showResult();
+
+#endif //DEBUG_PERF_HEADER \ No newline at end of file
bgstack15