// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary // source code may only be used and distributed under the Widevine License // Agreement. #ifndef WVCDM_METRICS_TIMER_METRIC_H_ #define WVCDM_METRICS_TIMER_METRIC_H_ #include namespace wvcdm { namespace metrics { class Timer { public: Timer() {} // Starts the clock running. If the clock was previously set, this resets it. // IsStarted will return true after this call. void Start(); // Returns whether or not the timer has started. bool IsStarted() const { return is_started_; } // Stops the clock and clears the current value. IsStarted will return false // after this call. void Clear(); // Returns the current clock value as milliseconds (AsMs) or microseconds // (AsUs). double AsMs() const; double AsUs() const; private: std::chrono::time_point start_; bool is_started_ = false; }; } // namespace metrics } // namespace wvcdm #endif // WVCDM_METRICS_TIMER_METRIC_H_