Files
android/libwvdrmengine/cdm/metrics/src/timer_metric.cpp
Aaron Vaage edb9f00df7 Widevine Metrics System
This change is the complete Widevine metrics system. It will
measure and record runtime information about what is happening
in the CDM - such as errors and throughput.

Bug: 33745339
Bug: 26027857
Change-Id: Ic9a82074f1e2b72c72d751b235f8ae361232787d
2017-01-27 16:59:17 -08:00

34 lines
798 B
C++

#include "timer_metric.h"
#include <stddef.h>
#include <sys/time.h>
namespace wvcdm {
namespace metrics {
void TimerMetric::Start() {
struct timeval tv;
gettimeofday(&tv, NULL);
sec_ = tv.tv_sec;
usec_ = tv.tv_usec;
}
double TimerMetric::AsMs() const {
struct timeval tv;
gettimeofday(&tv, NULL);
return usec_ > tv.tv_usec ?
(tv.tv_sec - sec_ - 1) * 1000.0 + (tv.tv_usec - usec_ + 1000000.0) / 1000.0 :
(tv.tv_sec - sec_) * 1000.0 + (tv.tv_usec - usec_) / 1000.0;
}
double TimerMetric::AsUs() const {
struct timeval tv;
gettimeofday(&tv, NULL);
return usec_ > tv.tv_usec ?
(tv.tv_sec - sec_ - 1) * 1000000.0 + (tv.tv_usec - usec_ + 1000000.0) :
(tv.tv_sec - sec_) * 1000000.0 + (tv.tv_usec - usec_);
}
} // namespace metrics
} // namespace wvcdm