Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More windows stuff...

  • Loading branch information...
commit 64453735706a30701661db0bc4b6bc8f567da375 1 parent cd423f5
@animetrics authored
View
17 include/UnitTest++/Win32/.svn/all-wcprops
@@ -0,0 +1,17 @@
+K 25
+svn:wc:ra_dav:version-url
+V 55
+/svnroot/unittest-cpp/!svn/ver/205/UnitTest++/src/Win32
+END
+TimeHelpers.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 71
+/svnroot/unittest-cpp/!svn/ver/205/UnitTest++/src/Win32/TimeHelpers.cpp
+END
+TimeHelpers.h
+K 25
+svn:wc:ra_dav:version-url
+V 69
+/svnroot/unittest-cpp/!svn/ver/205/UnitTest++/src/Win32/TimeHelpers.h
+END
View
96 include/UnitTest++/Win32/.svn/entries
@@ -0,0 +1,96 @@
+10
+
+dir
+207
+https://unittest-cpp.svn.sourceforge.net/svnroot/unittest-cpp/UnitTest++/src/Win32
+https://unittest-cpp.svn.sourceforge.net/svnroot/unittest-cpp
+
+
+
+2009-02-02T04:50:16.945106Z
+205
+cnicholson
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+feadf2a4-a60d-0410-a25d-8df00a7d1702
+
+TimeHelpers.cpp
+file
+
+
+
+
+2011-03-14T09:51:02.000000Z
+6c838740f3bb378bbdbd66efcdec989e
+2009-02-02T04:50:16.945106Z
+205
+cnicholson
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1094
+
+TimeHelpers.h
+file
+
+
+
+
+2011-03-14T09:51:02.000000Z
+2dafb4c49147ee5d68d1ef0413800fff
+2009-02-02T04:50:16.945106Z
+205
+cnicholson
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+586
+
View
5 include/UnitTest++/Win32/.svn/prop-base/TimeHelpers.cpp.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
View
5 include/UnitTest++/Win32/.svn/prop-base/TimeHelpers.h.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
View
47 include/UnitTest++/Win32/.svn/text-base/TimeHelpers.cpp.svn-base
@@ -0,0 +1,47 @@
+#include "TimeHelpers.h"
+#include <windows.h>
+
+namespace UnitTest {
+
+Timer::Timer()
+ : m_threadHandle(::GetCurrentThread())
+ , m_startTime(0)
+{
+#if defined(_MSC_VER) && (_MSC_VER == 1200) // VC6 doesn't have DWORD_PTR?
+ typedef unsigned long DWORD_PTR;
+#endif
+
+ DWORD_PTR systemMask;
+ ::GetProcessAffinityMask(GetCurrentProcess(), &m_processAffinityMask, &systemMask);
+ ::SetThreadAffinityMask(m_threadHandle, 1);
+ ::QueryPerformanceFrequency(reinterpret_cast< LARGE_INTEGER* >(&m_frequency));
+ ::SetThreadAffinityMask(m_threadHandle, m_processAffinityMask);
+}
+
+void Timer::Start()
+{
+ m_startTime = GetTime();
+}
+
+double Timer::GetTimeInMs() const
+{
+ __int64 const elapsedTime = GetTime() - m_startTime;
+ double const seconds = double(elapsedTime) / double(m_frequency);
+ return seconds * 1000.0;
+}
+
+__int64 Timer::GetTime() const
+{
+ LARGE_INTEGER curTime;
+ ::SetThreadAffinityMask(m_threadHandle, 1);
+ ::QueryPerformanceCounter(&curTime);
+ ::SetThreadAffinityMask(m_threadHandle, m_processAffinityMask);
+ return curTime.QuadPart;
+}
+
+void TimeHelpers::SleepMs(int const ms)
+{
+ ::Sleep(ms);
+}
+
+}
View
48 include/UnitTest++/Win32/.svn/text-base/TimeHelpers.h.svn-base
@@ -0,0 +1,48 @@
+#ifndef UNITTEST_TIMEHELPERS_H
+#define UNITTEST_TIMEHELPERS_H
+
+#include "../Config.h"
+
+
+#ifdef UNITTEST_MINGW
+ #ifndef __int64
+ #define __int64 long long
+ #endif
+#endif
+
+namespace UnitTest {
+
+class Timer
+{
+public:
+ Timer();
+ void Start();
+ double GetTimeInMs() const;
+
+private:
+ __int64 GetTime() const;
+
+ void* m_threadHandle;
+
+#if defined(_WIN64)
+ unsigned __int64 m_processAffinityMask;
+#else
+ unsigned long m_processAffinityMask;
+#endif
+
+ __int64 m_startTime;
+ __int64 m_frequency;
+};
+
+
+namespace TimeHelpers
+{
+void SleepMs (int ms);
+}
+
+
+}
+
+
+
+#endif
View
47 include/UnitTest++/Win32/TimeHelpers.cpp
@@ -0,0 +1,47 @@
+#include "TimeHelpers.h"
+#include <windows.h>
+
+namespace UnitTest {
+
+Timer::Timer()
+ : m_threadHandle(::GetCurrentThread())
+ , m_startTime(0)
+{
+#if defined(_MSC_VER) && (_MSC_VER == 1200) // VC6 doesn't have DWORD_PTR?
+ typedef unsigned long DWORD_PTR;
+#endif
+
+ DWORD_PTR systemMask;
+ ::GetProcessAffinityMask(GetCurrentProcess(), &m_processAffinityMask, &systemMask);
+ ::SetThreadAffinityMask(m_threadHandle, 1);
+ ::QueryPerformanceFrequency(reinterpret_cast< LARGE_INTEGER* >(&m_frequency));
+ ::SetThreadAffinityMask(m_threadHandle, m_processAffinityMask);
+}
+
+void Timer::Start()
+{
+ m_startTime = GetTime();
+}
+
+double Timer::GetTimeInMs() const
+{
+ __int64 const elapsedTime = GetTime() - m_startTime;
+ double const seconds = double(elapsedTime) / double(m_frequency);
+ return seconds * 1000.0;
+}
+
+__int64 Timer::GetTime() const
+{
+ LARGE_INTEGER curTime;
+ ::SetThreadAffinityMask(m_threadHandle, 1);
+ ::QueryPerformanceCounter(&curTime);
+ ::SetThreadAffinityMask(m_threadHandle, m_processAffinityMask);
+ return curTime.QuadPart;
+}
+
+void TimeHelpers::SleepMs(int const ms)
+{
+ ::Sleep(ms);
+}
+
+}
View
48 include/UnitTest++/Win32/TimeHelpers.h
@@ -0,0 +1,48 @@
+#ifndef UNITTEST_TIMEHELPERS_H
+#define UNITTEST_TIMEHELPERS_H
+
+#include "../Config.h"
+
+
+#ifdef UNITTEST_MINGW
+ #ifndef __int64
+ #define __int64 long long
+ #endif
+#endif
+
+namespace UnitTest {
+
+class Timer
+{
+public:
+ Timer();
+ void Start();
+ double GetTimeInMs() const;
+
+private:
+ __int64 GetTime() const;
+
+ void* m_threadHandle;
+
+#if defined(_WIN64)
+ unsigned __int64 m_processAffinityMask;
+#else
+ unsigned long m_processAffinityMask;
+#endif
+
+ __int64 m_startTime;
+ __int64 m_frequency;
+};
+
+
+namespace TimeHelpers
+{
+void SleepMs (int ms);
+}
+
+
+}
+
+
+
+#endif
Please sign in to comment.
Something went wrong with that request. Please try again.