Workaround for mediadrmserver spinning/battery drain problems. b/35093325 Change-Id: I71b32435c43d9e467c74d8c18e5a91af903f6b66
67 lines
1.3 KiB
C++
67 lines
1.3 KiB
C++
// Copyright 2016 Google Inc. All Rights Reserved.
|
|
|
|
#ifndef WVCDM_METRICS_METRICS_FRONT_END_H_
|
|
#define WVCDM_METRICS_METRICS_FRONT_END_H_
|
|
|
|
#include <map>
|
|
|
|
#include "report.h"
|
|
#include "timer_metric.h" /* needed for the macro */
|
|
|
|
namespace wvcdm {
|
|
namespace metrics {
|
|
|
|
class MetricsFrontEnd {
|
|
|
|
public:
|
|
|
|
MetricsFrontEnd(Report* root);
|
|
|
|
MetricNotification* CreateSubscriber();
|
|
|
|
static MetricsFrontEnd& Instance();
|
|
static void OverrideInstance(MetricsFrontEnd* instance);
|
|
|
|
private:
|
|
|
|
static MetricsFrontEnd* instance_;
|
|
|
|
Report* root_;
|
|
|
|
/* Disallow copy and assign. */
|
|
MetricsFrontEnd(const MetricsFrontEnd&);
|
|
void operator=(const MetricsFrontEnd&);
|
|
};
|
|
|
|
} // namespace metrics
|
|
} // namespace wvcdm
|
|
|
|
#define MFE wvcdm::metrics::MetricsFrontEnd::Instance()
|
|
|
|
#define NO_TIME 0
|
|
|
|
#if 0 // Disable metrics for now to work around P0:b/35093325
|
|
|
|
#define M_RECORD(GROUP, METRIC, TIME, ...)
|
|
#define M_TIME(CALL, GROUP, METRIC, ...)
|
|
|
|
#else // Re-enable when we have time to debug
|
|
|
|
#define M_RECORD(GROUP, METRIC, TIME, ...) \
|
|
if ( GROUP ) { \
|
|
( GROUP ) -> METRIC . Record( TIME, ##__VA_ARGS__ ); \
|
|
}
|
|
|
|
#define M_TIME(CALL, GROUP, METRIC, ...) \
|
|
if ( GROUP ) { \
|
|
wvcdm::metrics::TimerMetric timer; \
|
|
timer.Start(); \
|
|
CALL; \
|
|
( GROUP ) -> METRIC . Record(timer.AsUs(), ##__VA_ARGS__ ); \
|
|
} else { \
|
|
CALL; \
|
|
}
|
|
#endif // Disable
|
|
|
|
#endif
|