diff options
Diffstat (limited to 'src/mongo/db/stats/timer_stats.h')
-rw-r--r-- | src/mongo/db/stats/timer_stats.h | 84 |
1 files changed, 44 insertions, 40 deletions
diff --git a/src/mongo/db/stats/timer_stats.h b/src/mongo/db/stats/timer_stats.h index 9e3c4db5e5a..a1b3ef69dfd 100644 --- a/src/mongo/db/stats/timer_stats.h +++ b/src/mongo/db/stats/timer_stats.h @@ -36,54 +36,58 @@ namespace mongo { +/** + * Holds timing information in milliseconds + * keeps track of number of times and total milliseconds + * so a diff can be computed + */ +class TimerStats { +public: + void recordMillis(int millis); + /** - * Holds timing information in milliseconds - * keeps track of number of times and total milliseconds - * so a diff can be computed + * @return number of millis */ - class TimerStats { - public: - void recordMillis( int millis ); + int record(const Timer& timer); - /** - * @return number of millis - */ - int record( const Timer& timer ); + BSONObj getReport() const; + operator BSONObj() const { + return getReport(); + } - BSONObj getReport() const; - operator BSONObj() const { return getReport(); } +private: + mutable SpinLock _lock; + long long _num; + long long _totalMillis; +}; - private: - mutable SpinLock _lock; - long long _num; - long long _totalMillis; - }; +/** + * Holds an instance of a Timer such that we the time is recorded + * when the TimerHolder goes out of scope + */ +class TimerHolder { +public: + /** Destructor will record to TimerStats */ + TimerHolder(TimerStats* stats); + /** Will record stats if recordMillis hasn't (based on _recorded) */ + ~TimerHolder(); /** - * Holds an instance of a Timer such that we the time is recorded - * when the TimerHolder goes out of scope + * returns elapsed millis from internal timer */ - class TimerHolder { - public: - /** Destructor will record to TimerStats */ - TimerHolder( TimerStats* stats ); - /** Will record stats if recordMillis hasn't (based on _recorded) */ - ~TimerHolder(); + int millis() const { + return _t.millis(); + } - /** - * returns elapsed millis from internal timer - */ - int millis() const { return _t.millis(); } - - /** - * records the time in the TimerStats and marks that we've - * already recorded so the destructor doesn't - */ - int recordMillis(); + /** + * records the time in the TimerStats and marks that we've + * already recorded so the destructor doesn't + */ + int recordMillis(); - private: - TimerStats* _stats; - bool _recorded; - Timer _t; - }; +private: + TimerStats* _stats; + bool _recorded; + Timer _t; +}; } |