Spinning Topp Logo BlackTopp Studios
inc
testdatatools.cpp
Go to the documentation of this file.
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _testdatatools_cpp
41 #define _testdatatools_cpp
42 
43 /// @file
44 /// @brief The implementation of stuff that must be run in the context of a TestData
45 
46 #include "testdata.h"
47 
48 #include <vector>
49 #include <stdexcept>
50 #include <sstream>
51 
52 #ifdef _MEZZ_THREAD_WIN32_
53  #include <windows.h>
54 #else
55  #ifdef _MEZZ_THREAD_APPLE_
56  #include <sys/sysctl.h>
57  #endif
58  #include <sys/time.h>
59  #include <unistd.h>
60 #endif
61 
62 using namespace Mezzanine;
63 using namespace std;
64 
65 namespace Mezzanine
66 {
67  namespace Testing
68  {
69  #ifdef _MEZZ_THREAD_WIN32_
70  namespace
71  {
72  /// @internal
73  class Timer
74  {
75  public:
76  LARGE_INTEGER frequency;
77 
78  Timer()
79  { QueryPerformanceFrequency(&frequency); }
80 
82  {
83  LARGE_INTEGER Current;
84  QueryPerformanceCounter(&Current);
85  return MaxInt(Current.QuadPart * (1000000.0 / frequency.QuadPart));
86  }
87  };
88 
89  static Timer ATimer;
90  }
91 
92  MaxInt Now()
93  { return ATimer.GetTimeStamp(); }
94 
96  { return Whole(ATimer.frequency.QuadPart/1000); }
97 
98  #else
100  {
101  timeval Now;
102  gettimeofday(&Now, NULL); // Posix says this must return 0, so it seems it can't fail
103  return (Now.tv_sec * 1000000) + Now.tv_usec;
104  }
105 
107  { return 1; } // barring kernel bugs
108 
109  #endif
110  }// Testing
111 }// Mezzanine
112 
113 #endif
114 
MaxInt GetTimeStamp()
Get a timestamp, in microseconds. This will generally be some multiple of the GetTimeStampResolution ...
TestData, TestDataStorage and UnitTestGroup class definitions.
Whole NowResolution()
Get the resolution of the timestamp in microseconds. This is the smallest amount of time that the Get...
STL namespace.
MaxInt Now()
Get a timestamp, in microseconds. This will generally be some multiple of the GetTimeStampResolution ...
A basic timer class to assist in timed operations.
Definition: timer.h:67
long long MaxInt
A large integer type suitable for compile time math and long term microsecond time keeping...
Definition: datatypes.h:190
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151