There were warnings about unused parameters and unnecessary "const" that were hiding other warnings. This change resolves those warnings and resolves some constructor list ordering warnings that were hidden among the other warnings. Bug: 34784667 Change-Id: Ied78b00d3565abd66f90dbd1f4cce635dae7b957
54 lines
1.4 KiB
C++
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.).
|
|
double Min() const { return min_; }
|
|
double Max() const { return max_; }
|
|
double Mean() const { return mean_; }
|
|
int64_t Count() const { return count_; }
|
|
double Variance() const {
|
|
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_
|