Lines Matching refs:histogram
5 // Histogram is an object that aggregates statistics, and can summarize them in
10 #include "base/metrics/histogram.h"
25 const uint32 Histogram::kCrcTable[256] = {0x0, 0x77073096L, 0xee0e612cL,
71 typedef Histogram::Count Count;
74 const size_t Histogram::kBucketCount_MAX = 16384u;
76 Histogram* Histogram::FactoryGet(const std::string& name,
81 Histogram* histogram(NULL);
89 if (!StatisticsRecorder::FindHistogram(name, &histogram)) {
94 Histogram* tentative_histogram =
95 new Histogram(name, minimum, maximum, bucket_count);
98 histogram =
102 DCHECK_EQ(HISTOGRAM, histogram->histogram_type());
103 DCHECK(histogram->HasConstructorArguments(minimum, maximum, bucket_count));
104 return histogram;
107 Histogram* Histogram::FactoryTimeGet(const std::string& name,
116 void Histogram::Add(int value) {
127 void Histogram::AddBoolean(bool value) {
131 void Histogram::AddSampleSet(const SampleSet& sample) {
135 void Histogram::SetRangeDescriptions(const DescriptionPair descriptions[]) {
139 // The following methods provide a graphical histogram display.
140 void Histogram::WriteHTMLGraph(std::string* output) const {
147 void Histogram::WriteAscii(bool graph_it, const std::string& newline,
164 // nearly the largest bucket range without sliding over the histogram.
184 // Output the actual histogram graph.
212 std::string Histogram::SerializeHistogramInfo(const Histogram& histogram,
214 DCHECK_NE(NOT_VALID_IN_RENDERER, histogram.histogram_type());
217 pickle.WriteString(histogram.histogram_name());
218 pickle.WriteInt(histogram.declared_min());
219 pickle.WriteInt(histogram.declared_max());
220 pickle.WriteSize(histogram.bucket_count());
221 pickle.WriteUInt32(histogram.range_checksum());
222 pickle.WriteInt(histogram.histogram_type());
223 pickle.WriteInt(histogram.flags());
230 bool Histogram::DeserializeHistogramInfo(const std::string& histogram_info) {
254 !sample.Histogram::SampleSet::Deserialize(&iter, pickle)) {
255 LOG(ERROR) << "Pickle error decoding Histogram: " << histogram_name;
260 // checks above and beyond those in Histogram::Initialize()
263 LOG(ERROR) << "Values error decoding Histogram: " << histogram_name;
271 Histogram* render_histogram(NULL);
273 if (histogram_type == HISTOGRAM) {
274 render_histogram = Histogram::FactoryGet(
282 LOG(ERROR) << "Error Deserializing Histogram Unknown histogram_type: "
294 DVLOG(1) << "Single process mode, histogram observed and not copied: "
305 // Methods for the validating a sample and a related histogram.
308 Histogram::Inconsistencies Histogram::FindCorruption(
339 UMA_HISTOGRAM_COUNTS("Histogram.InconsistentCountHigh", delta);
344 UMA_HISTOGRAM_COUNTS("Histogram.InconsistentCountLow", -delta);
352 Histogram::ClassType Histogram::histogram_type() const {
353 return HISTOGRAM;
356 Histogram::Sample Histogram::ranges(size_t i) const {
360 size_t Histogram::bucket_count() const {
366 void Histogram::SnapshotSample(SampleSet* sample) const {
371 bool Histogram::HasConstructorArguments(Sample minimum,
378 bool Histogram::HasConstructorTimeDeltaArguments(TimeDelta minimum,
386 bool Histogram::HasValidRangeChecksum() const {
390 Histogram::Histogram(const std::string& name, Sample minimum,
403 Histogram::Histogram(const std::string& name, TimeDelta minimum,
416 Histogram::~Histogram() {
435 void Histogram::InitializeBucketRange() {
462 bool Histogram::PrintEmptyBucket(size_t index) const {
466 size_t Histogram::BucketIndex(Sample value) const {
491 // Use the actual bucket widths (like a linear histogram) until the widths get
496 double Histogram::GetBucketSize(Count current, size_t i) const {
505 void Histogram::ResetRangeChecksum() {
509 const std::string Histogram::GetAsciiBucketRange(size_t i) const {
518 // Update histogram data with new sample.
519 void Histogram::Accumulate(Sample value, Count count, size_t index) {
524 void Histogram::SetBucketRange(size_t i, Sample value) {
529 bool Histogram::ValidateBucketRanges() const {
539 uint32 Histogram::CalculateRangeChecksum() const {
547 void Histogram::Initialize() {
571 uint32 Histogram::Crc32(uint32 sum, Histogram::Sample range) {
575 Histogram::Sample range;
576 unsigned char bytes[sizeof(Histogram::Sample)];
586 Histogram::Sample range;
587 uint16 ints[sizeof(Histogram::Sample) / 2];
589 DCHECK_EQ(sizeof(Histogram::Sample), sizeof(converter));
601 double Histogram::GetPeakBucketSize(const SampleSet& snapshot) const {
611 void Histogram::WriteAsciiHeader(const SampleSet& snapshot,
615 "Histogram: %s recorded %d samples",
629 void Histogram::WriteAsciiBucketContext(const int64 past,
642 void Histogram::WriteAsciiBucketValue(Count current, double scaled_sum,
647 void Histogram::WriteAsciiBucketGraph(double current_size, double max_size,
662 // Methods for the Histogram::SampleSet class
665 Histogram::SampleSet::SampleSet()
671 Histogram::SampleSet::~SampleSet() {
674 void Histogram::SampleSet::Resize(const Histogram& histogram) {
675 counts_.resize(histogram.bucket_count(), 0);
678 void Histogram::SampleSet::CheckSize(const Histogram& histogram) const {
679 DCHECK_EQ(histogram.bucket_count(), counts_.size());
683 void Histogram::SampleSet::Accumulate(Sample value, Count count,
694 Count Histogram::SampleSet::TotalCount() const {
704 void Histogram::SampleSet::Add(const SampleSet& other) {
712 void Histogram::SampleSet::Subtract(const SampleSet& other) {
725 bool Histogram::SampleSet::Serialize(Pickle* pickle) const {
737 bool Histogram::SampleSet::Deserialize(void** iter, const Pickle& pickle) {
766 // LinearHistogram: This histogram uses a traditional set of evenly spaced
773 Histogram* LinearHistogram::FactoryGet(const std::string& name,
778 Histogram* histogram(NULL);
785 if (!StatisticsRecorder::FindHistogram(name, &histogram)) {
791 histogram =
795 DCHECK_EQ(LINEAR_HISTOGRAM, histogram->histogram_type());
796 DCHECK(histogram->HasConstructorArguments(minimum, maximum, bucket_count));
797 return histogram;
800 Histogram* LinearHistogram::FactoryTimeGet(const std::string& name,
809 Histogram::ClassType LinearHistogram::histogram_type() const {
824 : Histogram(name, minimum >= 1 ? minimum : 1, maximum, bucket_count) {
831 : Histogram(name, minimum >= TimeDelta::FromMilliseconds(1) ?
852 // samples in a histogram if we didn't normalize this way.
861 return Histogram::GetAsciiBucketRange(i);
874 Histogram* BooleanHistogram::FactoryGet(const std::string& name, Flags flags) {
875 Histogram* histogram(NULL);
877 if (!StatisticsRecorder::FindHistogram(name, &histogram)) {
882 histogram =
886 DCHECK_EQ(BOOLEAN_HISTOGRAM, histogram->histogram_type());
887 return histogram;
890 Histogram::ClassType BooleanHistogram::histogram_type() const {
906 Histogram* CustomHistogram::FactoryGet(const std::string& name,
909 Histogram* histogram(NULL);
924 if (!StatisticsRecorder::FindHistogram(name, &histogram)) {
929 histogram =
933 DCHECK_EQ(histogram->histogram_type(), CUSTOM_HISTOGRAM);
934 DCHECK(histogram->HasConstructorArguments(ranges[1], ranges.back(),
936 return histogram;
939 Histogram::ClassType CustomHistogram::histogram_type() const {
945 : Histogram(name, custom_ranges[1], custom_ranges.back(),
1016 Histogram* StatisticsRecorder::RegisterOrDeleteDuplicate(Histogram* histogram) {
1017 DCHECK(histogram->HasValidRangeChecksum());
1019 return histogram;
1022 return histogram;
1023 const std::string name = histogram->histogram_name();
1027 (*histograms_)[name] = histogram;
1029 delete histogram; // We already have one by this name.
1030 histogram = it->second;
1032 return histogram;
1095 Histogram** histogram) {
1104 *histogram = it->second;