Files
android/libwvdrmengine/cdm/metrics/include/timer_metric.h
Alex Dale 1b95db51f1 Updated copyright notice and cleaned up includes.
[ Merge of http://go/wvgerrit/137810 ]

Bug: 204946540
Test: Metric unit tests
Change-Id: I78f839fafd27604a2bb78c04d587c40919c5372d
2021-11-03 17:28:00 -07:00

35 lines
1.1 KiB
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 TimerMetric {
public:
// Constructs a new TimerMetric.
explicit TimerMetric() : is_started_(false) {}
// 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::steady_clock clock_;
std::chrono::time_point<std::chrono::steady_clock> start_;
bool is_started_;
};
} // namespace metrics
} // namespace wvcdm
#endif // WVCDM_METRICS_TIMER_METRIC_H_