// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary // source code may only be used and distributed under the Widevine License // Agreement. #include "timer_metric.h" namespace wvcdm { namespace metrics { using ClockType = std::chrono::steady_clock; using TimePoint = std::chrono::time_point; void Timer::Start() { start_ = ClockType::now(); is_started_ = true; } void Timer::Clear() { is_started_ = false; } double Timer::AsMs() const { if (!is_started_) return 0.0; const TimePoint end = ClockType::now(); return (end - start_) / std::chrono::milliseconds(1); } double Timer::AsUs() const { if (!is_started_) return 0.0; const TimePoint end = ClockType::now(); return (end - start_) / std::chrono::microseconds(1); } } // namespace metrics } // namespace wvcdm