GteTimer.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
10 #include <GTEngineDEF.h>
11 #include <cstdint>
12 
13 #if defined(__MSWINDOWS__) && _MSC_VER < 1900
14 // MSVS 2013 has an implementation of std::chrono::high_resolution_clock
15 // that does not use a 64-bit clock (QueryPerformanceCounter). Instead,
16 // it appears to use a file-system clock that is 24 bits. To obtain
17 // accurate measurements, we need the 64-bit clock. However, MSVS 2015
18 // does use a 64-bit clock.
19 #define GTE_NEEDS_64_BIT_CLOCK
20 #endif
21 
22 #if !defined(GTE_NEEDS_64_BIT_CLOCK)
23 #include <chrono>
24 #endif
25 
26 namespace gte
27 {
28 
30 {
31 public:
32  // Construction of a high-resolution timer (64-bit).
33  Timer();
34 
35  // Get the current time relative to the initial time.
36  int64_t GetNanoseconds() const;
37  int64_t GetMicroseconds() const;
38  int64_t GetMilliseconds() const;
39  double GetSeconds() const;
40 
41  // Reset so that the current time is the initial time.
42  void Reset();
43 
44 private:
45 #if defined(GTE_NEEDS_64_BIT_CLOCK)
46  // Internally use QueryPerformanceCounter.
47  int64_t GetTicks() const;
48 
49  int64_t mFrequency, mInitialTicks;
50  double mInvFrequency;
51 #else
52  std::chrono::high_resolution_clock::time_point mInitialTime;
53 #endif
54 };
55 
56 }
std::chrono::high_resolution_clock::time_point mInitialTime
Definition: GteTimer.h:52
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:01