NeuralEngine A Game Engine with embeded Machine Learning algorithms based on Gaussian Processes. |

NeTimer.h
1
11#pragma once
12
13#include <NeCoreLib.h>
14#include <cstdint>
15
16#if defined(__MSWINDOWS__) && _MSC_VER < 1900
17// MSVS 2013 has an implementation of std::chrono::high_resolution_clock
18// that does not use a 64-bit clock (QueryPerformanceCounter). Instead,
19// it appears to use a file-system clock that is 24 bits. To obtain
20// accurate measurements, we need the 64-bit clock. However, MSVS 2015
21// does use a 64-bit clock.
22#define NE_NEEDS_64_BIT_CLOCK
23#endif
24
25#if !defined(NE_NEEDS_64_BIT_CLOCK)
26#include <chrono>
27#endif
28
29 namespace NeuralEngine
30{
31
32 class NE_IMPEXP Timer
33 {
34 public:
35 // Construction of a high-resolution timer (64-bit).
36 Timer();
37
38 // Get the current time relative to the initial time.
39 int64_t GetNanoseconds() const;
40 int64_t GetMicroseconds() const;
41 int64_t GetMilliseconds() const;
42 double GetSeconds() const;
43
44 // Reset so that the current time is the initial time.
45 void Reset();
46
47 private:
48#if defined(NE_NEEDS_64_BIT_CLOCK)
49 // Internally use QueryPerformanceCounter.
50 int64_t GetTicks() const;
51
52 int64_t mFrequency, mInitialTicks;
53 double mInvFrequency;
54#else
55 std::chrono::high_resolution_clock::time_point mInitialTime;
56#endif
57 };
58
59}
NeuralEngine::Timer
Definition: NeTimer.h:33
NeuralEngine
Definition: NeArray2.h:18