GteOnIdleTimer.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 <chrono>
12 #include <cstdint>
13 #include <string>
14 
15 namespace gte
16 {
17 
19 {
20 public:
21  // The 'frequency' is how many calls of OnIdle() occur before the
22  // high-frequency clock is called.
23  OnIdleTimer(int64_t frequency = 30);
24 
25  // Restart the timer from zero. This is useful to call after the
26  // application has "warmed up."
27  void Reset();
28 
29  // Call this function at the beginning of OnIdle().
30  void Measure();
31 
32  // Call this function at the end of OnIdle();
33  inline void UpdateFrameCount();
34 
35  // Report the rates.
36  double GetFramesPerSecond() const;
37  double GetSecondsPerFrame() const;
38  int64_t GetMillisecondsPerFrame() const;
39 
40  // For convenience in displaying a formatted frames-per-second string.
41  std::string GetFPS() const;
42 
43 private:
44  // The accumulated time is measured in milliseconds.
45  int64_t mFrequency, mCallCount;
46  int64_t mFrameCount, mAccumulatedFrameCount, mAccumulatedTime;
47  std::chrono::high_resolution_clock::time_point mTime0, mTime1;
48 };
49 
50 
52 {
53  ++mFrameCount;
54 }
55 
56 
57 }
std::chrono::high_resolution_clock::time_point mTime1
GLsizei const GLchar *const * string
Definition: glcorearb.h:809
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63


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