Home | History | Annotate | Download | only in base

Lines Matching refs:HISTOGRAM

5 // Histogram is an object that aggregates statistics, and can summarize them in
10 #include "base/histogram.h"
21 typedef Histogram::Count Count;
23 scoped_refptr<Histogram> Histogram::FactoryGet(const std::string& name,
25 scoped_refptr<Histogram> histogram(NULL);
33 if (StatisticsRecorder::FindHistogram(name, &histogram)) {
34 DCHECK(histogram.get() != NULL);
36 histogram = new Histogram(name, minimum, maximum, bucket_count);
37 scoped_refptr<Histogram> registered_histogram(NULL);
41 registered_histogram.get() != histogram.get())
42 histogram = registered_histogram;
45 DCHECK(HISTOGRAM == histogram->histogram_type());
46 DCHECK(histogram->HasConstructorArguments(minimum, maximum, bucket_count));
47 histogram->SetFlags(flags);
48 return histogram;
51 scoped_refptr<Histogram> Histogram::FactoryGet(const std::string& name,
58 Histogram::Histogram(const std::string& name, Sample minimum,
70 Histogram::Histogram(const std::string& name, TimeDelta minimum,
82 Histogram::~Histogram() {
93 void Histogram::Add(int value) {
104 void Histogram::AddSampleSet(const SampleSet& sample) {
108 // The following methods provide a graphical histogram display.
109 void Histogram::WriteHTMLGraph(std::string* output) const {
116 void Histogram::WriteAscii(bool graph_it, const std::string& newline,
133 // nearly the largest bucket range without sliding over the histogram.
153 // Output the actual histogram graph.
180 bool Histogram::ValidateBucketRanges() const {
190 void Histogram::Initialize() {
215 void Histogram::InitializeBucketRange() {
241 size_t Histogram::BucketIndex(Sample value) const {
265 // Use the actual bucket widths (like a linear histogram) until the widths get
270 double Histogram::GetBucketSize(Count current, size_t i) const {
286 // Update histogram data with new sample.
287 void Histogram::Accumulate(Sample value, Count count, size_t index) {
294 void Histogram::SnapshotSample(SampleSet* sample) const {
302 void Histogram::SetBucketRange(size_t i, Sample value) {
310 double Histogram::GetPeakBucketSize(const SampleSet& snapshot) const {
320 void Histogram::WriteAsciiHeader(const SampleSet& snapshot,
324 "Histogram: %s recorded %d samples",
343 void Histogram::WriteAsciiBucketContext(const int64 past,
356 const std::string Histogram::GetAsciiBucketRange(size_t i) const {
365 void Histogram::WriteAsciiBucketValue(Count current, double scaled_sum,
370 void Histogram::WriteAsciiBucketGraph(double current_size, double max_size,
385 std::string Histogram::SerializeHistogramInfo(const Histogram& histogram,
387 DCHECK(histogram.histogram_type() != NOT_VALID_IN_RENDERER);
390 pickle.WriteString(histogram.histogram_name());
391 pickle.WriteInt(histogram.declared_min());
392 pickle.WriteInt(histogram.declared_max());
393 pickle.WriteSize(histogram.bucket_count());
394 pickle.WriteInt(histogram.histogram_type());
395 pickle.WriteInt(histogram.flags());
402 bool Histogram::DeserializeHistogramInfo(const std::string& histogram_info) {
424 !sample.Histogram::SampleSet::Deserialize(&iter, pickle)) {
425 LOG(ERROR) << "Pickle error decoding Histogram: " << histogram_name;
430 // checks above and beyond those in Histogram::Initialize()
433 LOG(ERROR) << "Values error decoding Histogram: " << histogram_name;
441 scoped_refptr<Histogram> render_histogram(NULL);
443 if (histogram_type == HISTOGRAM) {
444 render_histogram = Histogram::FactoryGet(
452 LOG(ERROR) << "Error Deserializing Histogram Unknown histogram_type: " <<
463 DLOG(INFO) << "Single process mode, histogram observed and not copied: " <<
474 // Methods for the Histogram::SampleSet class
477 Histogram::SampleSet::SampleSet()
483 void Histogram::SampleSet::Resize(const Histogram& histogram) {
484 counts_.resize(histogram.bucket_count(), 0);
487 void Histogram::SampleSet::CheckSize(const Histogram& histogram) const {
488 DCHECK(counts_.size() == histogram.bucket_count());
492 void Histogram::SampleSet::Accumulate(Sample value, Count count,
503 Count Histogram::SampleSet::TotalCount() const {
513 void Histogram::SampleSet::Add(const SampleSet& other) {
521 void Histogram::SampleSet::Subtract(const SampleSet& other) {
534 bool Histogram::SampleSet::Serialize(Pickle* pickle) const {
546 bool Histogram::SampleSet::Deserialize(void** iter, const Pickle& pickle) {
573 // LinearHistogram: This histogram uses a traditional set of evenly spaced
577 scoped_refptr<Histogram> LinearHistogram::FactoryGet(
580 scoped_refptr<Histogram> histogram(NULL);
587 if (StatisticsRecorder::FindHistogram(name, &histogram)) {
588 DCHECK(histogram.get() != NULL);
590 histogram = new LinearHistogram(name, minimum, maximum, bucket_count);
591 scoped_refptr<Histogram> registered_histogram(NULL);
594 registered_histogram.get() != histogram.get())
595 histogram = registered_histogram;
598 DCHECK(LINEAR_HISTOGRAM == histogram->histogram_type());
599 DCHECK(histogram->HasConstructorArguments(minimum, maximum, bucket_count));
600 histogram->SetFlags(flags);
601 return histogram;
604 scoped_refptr<Histogram> LinearHistogram::FactoryGet(const std::string& name,
613 : Histogram(name, minimum >= 1 ? minimum : 1, maximum, bucket_count) {
620 : Histogram(name, minimum >= TimeDelta::FromMilliseconds(1) ?
639 return Histogram::GetAsciiBucketRange(i);
663 // samples in a histogram if we didn't normalize this way.
672 scoped_refptr<Histogram> BooleanHistogram::FactoryGet(const std::string& name,
674 scoped_refptr<Histogram> histogram(NULL);
676 if (StatisticsRecorder::FindHistogram(name, &histogram)) {
677 DCHECK(histogram.get() != NULL);
679 histogram = new BooleanHistogram(name);
680 scoped_refptr<Histogram> registered_histogram(NULL);
683 registered_histogram.get() != histogram.get())
684 histogram = registered_histogram;
687 DCHECK(BOOLEAN_HISTOGRAM == histogram->histogram_type());
688 histogram->SetFlags(flags);
689 return histogram;
728 // Note: We can't accept a ref_ptr to |histogram| because we *might* not keep a
729 // reference, and we are called while in the Histogram constructor. In that
730 // scenario, a ref_ptr would have incremented the ref count when the histogram
734 void StatisticsRecorder::Register(Histogram* histogram) {
737 const std::string name = histogram->histogram_name();
742 (*histograms_)[name] = histogram;
803 scoped_refptr<Histogram>* histogram) {
810 *histogram = it->second;