// Creates a data histogram for a better understanding of statistical data. // Histogram analysis goes beyond simple mean and standard deviation to provide // percentiles values, describing where the $% of the input data lies. // Designed to be simple and used with timing logger in art.
// Minimum and initial number of allocated buckets in histogram. static constexpr size_t kMinBuckets = 8; // Used by the cumulative timing logger to search the histogram set using for an existing split // with the same name using CumulativeLogger::HistogramComparator. explicit Histogram(constchar* name); // This is the expected constructor when creating new Histograms. Max_buckets must be even. // Max_buckets, if specified, must be at least kMinBuckets.
Histogram(constchar* name, Value initial_bucket_width, size_t max_buckets = 100); void AddValue(Value); void AdjustAndAddValue(Value); // Add a value after dividing it by kAdjust. // Builds the cumulative distribution function from the frequency data. // Accumulative summation of frequencies. // cumulative_freq[i] = sum(frequency[j] : 0 < j < i ) // Accumulative summation of percentiles; which is the frequency / SampleSize // cumulative_perc[i] = sum(frequency[j] / SampleSize : 0 < j < i ) void CreateHistogram(CumulativeData* data) const; // Reset the cumulative values, next time CreateHistogram is called it will recreate the cache. void Reset(); double Mean() const; double Variance() const; double Percentile(double per, const CumulativeData& data) const; void PrintConfidenceIntervals(std::ostream& os, double interval, const CumulativeData& data) const; void PrintMemoryUse(std::ostream& os) const; void PrintBins(std::ostream& os, const CumulativeData& data) const; void DumpBins(std::ostream& os) const;
Value GetRange(size_t bucket_idx) const;
size_t GetBucketCount() const;
Value AdjustedSum() const { return sum_ * kAdjust;
}
Value Min() const { return min_value_added_;
}
Value Max() const { return max_value_added_;
}
Value BucketWidth() const { return bucket_width_;
}
const std::string& Name() const { return name_;
}
private: void Initialize();
size_t FindBucket(Value val) const; void BucketiseValue(Value val); // Add more buckets to the histogram to fill in a new value that exceeded // the max_read_value_. void GrowBuckets(Value val);
std::string name_; // Maximum number of buckets. const size_t max_buckets_; // Number of samples placed in histogram.
size_t sample_size_; // Width of the bucket range. The lower the value is the more accurate // histogram percentiles are. Grows adaptively when we hit max buckets.
Value bucket_width_; // How many occurrences of values fall within a bucket at index i where i covers the range // starting at min_ + i * bucket_width_ with size bucket_size_.
std::vector<uint32_t> frequency_; // Summation of all the elements inputed by the user.
Value sum_; // Minimum value that can fit in the histogram. Fixed to zero for now.
Value min_; // Maximum value that can fit in the histogram, grows adaptively.
Value max_; // Summation of the values entered. Used to calculate variance.
Value sum_of_squares_; // Maximum value entered in the histogram.
Value min_value_added_; // Minimum value entered in the histogram.
Value max_value_added_;
DISALLOW_COPY_AND_ASSIGN(Histogram);
};
} // namespace art
#endif// ART_LIBARTBASE_BASE_HISTOGRAM_H_
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.9 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.