Files
android/libwvdrmengine/cdm/metrics/include/timer_metric.h
Alex Dale f5759c5149 Updated metric Distribution and Timer utils.
[ Merge of http://go/wvgerrit/137811 ]

Renamed TimerMetric to Timer.  Timer is used to generate durations
included in metrics, but is not a metric itself.  The method of
getting the current time did not require creating an instance of
std::steady_clock.

Updated Distribution and Timer to use default initializers instead of
constructor initialization list.

Bug: 204946540
Test: Metric unit tests
Change-Id: I7ed291b586347dd0b7ab305960883bec04637315
2021-11-05 15:12:09 -07:00

33 lines
1023 B
C++

// 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 <chrono>
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<std::chrono::steady_clock> start_;
bool is_started_ = false;
};
} // namespace metrics
} // namespace wvcdm
#endif // WVCDM_METRICS_TIMER_METRIC_H_