Bug 837271 - part 1 - add means to control computation of extended statistics to histogram code; r=vladan

This commit is contained in:
Nathan Froyd 2013-02-13 10:31:25 -05:00
Родитель 8ba2f637aa
Коммит ca45b07a60
2 изменённых файлов: 14 добавлений и 7 удалений

Просмотреть файл

@ -559,7 +559,8 @@ const std::string Histogram::GetAsciiBucketRange(size_t i) const {
// Update histogram data with new sample.
void Histogram::Accumulate(Sample value, Count count, size_t index) {
// Note locking not done in this version!!!
sample_.AccumulateWithExponentialStats(value, count, index);
sample_.AccumulateWithExponentialStats(value, count, index,
flags_ & kExtendedStatisticsFlag);
}
void Histogram::SetBucketRange(size_t i, Sample value) {
@ -743,12 +744,15 @@ void Histogram::SampleSet::AccumulateWithLinearStats(Sample value,
void Histogram::SampleSet::AccumulateWithExponentialStats(Sample value,
Count count,
size_t index) {
size_t index,
bool computeExtendedStatistics) {
Accumulate(value, count, index);
DCHECK_GE(value, 0);
float value_log = logf(static_cast<float>(value) + 1.0f);
log_sum_ += count * value_log;
log_sum_squares_ += count * value_log * value_log;
if (computeExtendedStatistics) {
DCHECK_GE(value, 0);
float value_log = logf(static_cast<float>(value) + 1.0f);
log_sum_ += count * value_log;
log_sum_squares_ += count * value_log * value_log;
}
}
Count Histogram::SampleSet::TotalCount() const {

Просмотреть файл

@ -290,6 +290,7 @@ class Histogram {
enum Flags {
kNoFlags = 0,
kUmaTargetedHistogramFlag = 0x1, // Histogram should be UMA uploaded.
kExtendedStatisticsFlag = 0x2, // OK to gather extended statistics on histograms.
// Indicate that the histogram was pickled to be sent across an IPC Channel.
// If we observe this flag on a histogram being aggregated into after IPC,
@ -336,7 +337,9 @@ class Histogram {
// Accessor for histogram to make routine additions.
void AccumulateWithLinearStats(Sample value, Count count, size_t index);
// Alternate routine for exponential histograms.
void AccumulateWithExponentialStats(Sample value, Count count, size_t index);
// computeExpensiveStatistics should be true if we want to compute log sums.
void AccumulateWithExponentialStats(Sample value, Count count, size_t index,
bool computeExtendedStatistics);
// Accessor methods.
Count counts(size_t i) const { return counts_[i]; }