16 #ifndef SURGSIM_FRAMEWORK_TIMER_H 17 #define SURGSIM_FRAMEWORK_TIMER_H 19 #include <boost/chrono.hpp> 20 #include <boost/thread/shared_mutex.hpp> 100 typedef boost::chrono::steady_clock TimerClock;
103 typedef boost::chrono::duration<double> TimerDuration;
106 typedef boost::chrono::time_point<TimerClock, TimerDuration> TimerTimePoint;
110 TimerTimePoint now();
113 static const TimerClock m_clock;
116 TimerTimePoint m_lastTime;
119 size_t m_maxNumberOfFrames;
122 std::deque<TimerDuration> m_frameDurations;
125 mutable boost::shared_mutex m_sharedMutex;
128 std::atomic<size_t> m_clockFails;
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Timer()
Instantiate a TimerClock and start a timing run.
Definition: Timer.cpp:26
double getCumulativeTime() const
Return the sum of the durations over all the stored frames.
Definition: Timer.cpp:70
double getAverageFrameRate() const
Return the inverse of the average duration across all stored frames.
Definition: Timer.cpp:111
Timer class, measures execution times.
Definition: Timer.h:31
size_t getCurrentNumberOfFrames() const
Definition: Timer.cpp:147
double getMaxFramePeriod() const
Definition: Timer.cpp:170
double getLastFrameRate() const
Return the inverse of the duration of the most-recent frame.
Definition: Timer.cpp:125
double getLastFramePeriod() const
Return the duration of the most-recent frame (time between last endFrame and the previous start...
Definition: Timer.cpp:116
void setMaxNumberOfFrames(size_t numberOfFrames)
Set the maximum number of frames to store.
Definition: Timer.cpp:130
void start()
Begin a timing run by clearing out any stored frames and beginning a frame.
Definition: Timer.cpp:32
void endFrame()
End this frame by storing the duration since the current frame was begun.
Definition: Timer.cpp:48
double getMinFramePeriod() const
Definition: Timer.cpp:179
size_t getNumberOfClockFails() const
Definition: Timer.cpp:154
double getCurrentTime()
Return the amount of time spent in the current frame.
Definition: Timer.cpp:85
bool isBufferFull() const
Definition: Timer.cpp:188
size_t getMaxNumberOfFrames()
Definition: Timer.cpp:142
double getAverageFramePeriod() const
Return the average duration across all stored frames.
Definition: Timer.cpp:92
void markFrame()
End the current frame and begin a new frame.
Definition: Timer.cpp:64
void beginFrame()
Begin a frame (storing the current time).
Definition: Timer.cpp:43