| 1 |
/*** |
| 2 |
* This file is based on or incorporates material from the UnitTest++ r30 open source project. |
| 3 |
* Microsoft is not the original author of this code but has modified it and is licensing the code under |
| 4 |
* the MIT License. Microsoft reserves all other rights not expressly granted under the MIT License, |
| 5 |
* whether by implication, estoppel or otherwise. |
| 6 |
* |
| 7 |
* UnitTest++ r30 |
| 8 |
* |
| 9 |
* Copyright (c) 2006 Noel Llopis and Charles Nicholson |
| 10 |
* Portions Copyright (c) Microsoft Corporation |
| 11 |
* |
| 12 |
* All Rights Reserved. |
| 13 |
* |
| 14 |
* MIT License |
| 15 |
* |
| 16 |
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
| 17 |
* and associated documentation files (the "Software"), to deal in the Software without restriction, |
| 18 |
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 19 |
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, |
| 20 |
* subject to the following conditions: |
| 21 |
* |
| 22 |
* The above copyright notice and this permission notice shall be included in all copies or |
| 23 |
* substantial portions of the Software. |
| 24 |
* |
| 25 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, |
| 26 |
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE |
| 27 |
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 28 |
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 29 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 30 |
***/ |
| 31 |
|
| 32 |
#ifndef UNITTEST_TIMEHELPERS_H |
| 33 |
#define UNITTEST_TIMEHELPERS_H |
| 34 |
|
| 35 |
#include "../../config.h" |
| 36 |
#include "../HelperMacros.h" |
| 37 |
|
| 38 |
#ifdef UNITTEST_MINGW |
| 39 |
#ifndef __int64 |
| 40 |
#define __int64 long long |
| 41 |
#endif |
| 42 |
#endif |
| 43 |
|
| 44 |
namespace UnitTest |
| 45 |
{ |
| 46 |
class Timer |
| 47 |
{ |
| 48 |
public: |
| 49 |
UNITTEST_LINKAGE Timer(); |
| 50 |
UNITTEST_LINKAGE void Start(); |
| 51 |
UNITTEST_LINKAGE double GetTimeInMs() const; |
| 52 |
|
| 53 |
private: |
| 54 |
__int64 GetTime() const; |
| 55 |
|
| 56 |
void* m_threadHandle; |
| 57 |
|
| 58 |
#if defined(_WIN64) |
| 59 |
unsigned __int64 m_processAffinityMask; |
| 60 |
#else |
| 61 |
unsigned long m_processAffinityMask; |
| 62 |
#endif |
| 63 |
|
| 64 |
__int64 m_startTime; |
| 65 |
__int64 m_frequency; |
| 66 |
}; |
| 67 |
|
| 68 |
namespace TimeHelpers |
| 69 |
{ |
| 70 |
UNITTEST_LINKAGE void SleepMs(int ms); |
| 71 |
} |
| 72 |
|
| 73 |
} // namespace UnitTest |
| 74 |
|
| 75 |
#endif |