CMU462 Library  1.0
15-462/15-662: Computer Graphics (Fall 2015)
timer.h
1 #ifndef CMU462_TIMER_H
2 #define CMU462_TIMER_H
3 
4 #include "CMU462.h"
5 #include <chrono>
6 
7 namespace CMU462 {
8 
12 class Timer {
13  public:
14 
18  inline void start() {
19  t0 = std::chrono::steady_clock::now();
20  }
21 
25  inline void stop() {
26  t1 = std::chrono::steady_clock::now();
27  }
28 
32  inline double duration() {
33  return (std::chrono::duration<double>(t1 - t0)).count();
34  }
35 
36  private:
37 
38  std::chrono::time_point<std::chrono::steady_clock> t0;
39  std::chrono::time_point<std::chrono::steady_clock> t1;
40 
41 };
42 
43 } // namespace CMU462
44 
45 #endif //CMU462_TIMER_H
Definition: CMU462.h:8
double duration()
Return duration between the last call to start and last call to stop.
Definition: timer.h:32
void stop()
Stops the timer.
Definition: timer.h:25
void start()
Starts the timer.
Definition: timer.h:18
A basic timer class.
Definition: timer.h:12