Knight's Tour Generator
Tourneys and the Fast Generation and Obfuscation of Closed Knight's Tours
Timer.h
Go to the documentation of this file.
1 
4 // MIT License
5 //
6 // Copyright (c) 2019 Ian Parberry
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 
26 #ifndef __Timer__
27 #define __Timer__
28 
29 #include "Includes.h"
30 #include "Defines.h"
31 
32 typedef std::chrono::system_clock sysclock;
33 typedef std::chrono::time_point<sysclock> systime_point;
34 
42 
43 class CTimer{
44  private:
47  std::string m_strTimeAndDate;
48 
49  const char* GetDateAndTime(const systime_point p);
50  UINT CPUTime();
51 
52  public:
53  const char* GetStartDateAndTime();
54  const char* GetCurrentDateAndTime();
55 
56  void Start();
57  float GetElapsedTime();
58  float GetCPUTime();
59  void Finish();
60 }; //CTimer
61 
62 #endif
std::chrono::time_point< sysclock > systime_point
System time point.
Definition: Timer.h:33
const char * GetCurrentDateAndTime()
Get current time and date.
Definition: Timer.cpp:61
systime_point m_tpElapsedTimeStart
Clock time.
Definition: Timer.h:45
UINT CPUTime()
Platform independent CPU time.
Definition: Timer.cpp:117
Defines, enumerated types, and typedefs.
const char * GetDateAndTime(const systime_point p)
Get time and date.
Definition: Timer.cpp:43
const char * GetStartDateAndTime()
Get start time and date.
Definition: Timer.cpp:53
void Start()
Start timing.
Definition: Timer.cpp:32
Useful includes.
Timer for elapsed time and CPU time.
Definition: Timer.h:43
unsigned int UINT
Abbreviation for unsigned integer.
Definition: Defines.h:84
float GetCPUTime()
Get CPU time in seconds.
Definition: Timer.cpp:76
void Finish()
Print CPU and elapsed time.
Definition: Timer.cpp:83
std::chrono::system_clock sysclock
System clock.
Definition: Timer.h:32
std::string m_strTimeAndDate
Container for time and date string.
Definition: Timer.h:47
float GetElapsedTime()
Get elapsed time in seconds.
Definition: Timer.cpp:68
float m_fCPUTimeStart
CPU time in seconds.
Definition: Timer.h:46