Files
android/libwvdrmengine/cdm/metrics/include/distribution.h
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

54 lines
1.4 KiB
C++

// Copyright 2017 Google Inc. All Rights Reserved.
//
// This file contains the definition of a Distribution class which computes
// the distribution values of a series of samples.
#ifndef WVCDM_METRICS_DISTRIBUTION_H_
#define WVCDM_METRICS_DISTRIBUTION_H_
#include <stdint.h>
namespace wvcdm {
namespace metrics {
// The Distribution class holds statistics about a series of values that the
// client provides via the Record method. A caller will call Record once for
// each of the values in a series. The Distribution instance will calculate the
// mean, count, min, max and variance of the distribution.
//
// Example usage:
// Distribution dist;
// dist.Record(1);
// dist.Record(2);
// dist.Mean(); // Returns 1.5.
// dist.Count(); // Returns 2.
class Distribution {
public:
Distribution();
// Uses the provided sample value to update the computed statistics.
void Record(double value);
// Return the value for each of the stats computed about the series of
// values (min, max, count, etc.).
const double Min() { return min_; }
const double Max() { return max_; }
const double Mean() { return mean_; }
const int64_t Count() { return count_; }
const double Variance() {
return count_ == 0 ? 0.0 : sum_squared_deviation_ / count_;
}
private:
int64_t count_;
double min_;
double max_;
double mean_;
double sum_squared_deviation_;
};
} // namespace metrics
} // namespace wvcdm
#endif // WVCDM_METRICS_DISTRIBUTION_H_