@@ -30,7 +30,7 @@ typedef std::chrono::time_point<clock_> time_point_;
3030template <typename ResolutionRatio = std::ratio<1 > >
3131class Timer : public peloton ::Printable {
3232 public:
33- Timer () : elapsed_(0 ), invocations_(0 ) {}
33+ Timer () : elapsed_(0 ), total_( 0 ), invocations_(0 ) {}
3434
3535 inline void Start () { begin_ = clock_::now (); }
3636
@@ -43,16 +43,33 @@ class Timer : public peloton::Printable {
4343 .count ();
4444
4545 elapsed_ += duration;
46+ total_ += duration;
4647 invocations_++;
4748 }
4849
49- inline void Reset () { elapsed_ = 0 ; }
50-
51- // Get Elapsed duration
52- inline double GetDuration () const { return elapsed_; }
53-
54- // Get Number of invocations
55- inline int GetInvocations () const { return invocations_; }
50+ /* *
51+ * Reset the current elapsed time counter.
52+ */
53+ void Reset () { elapsed_ = 0 ; }
54+
55+ /* *
56+ * Get elapsed duration
57+ * @return
58+ */
59+ double GetDuration () const { return elapsed_; }
60+
61+ /* *
62+ * Return the total amount of time measured by
63+ * this timer after multiple invocations.
64+ * @return
65+ */
66+ double GetTotalDuration () const { return (total_); }
67+
68+ /* *
69+ * Get number of invocations
70+ * @return
71+ */
72+ int GetInvocations () const { return invocations_; }
5673
5774 // Get a string representation for debugging
5875 inline const std::string GetInfo () const {
@@ -73,6 +90,11 @@ class Timer : public peloton::Printable {
7390 // Elapsed time (with desired resolution)
7491 double elapsed_;
7592
93+ /* *
94+ * Total amount of time (even after resets)
95+ */
96+ double total_;
97+
7698 // Number of invocations
7799 int invocations_;
78100};
0 commit comments