OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Histogram is an object that aggregates statistics, and can summarize them in | 5 // Histogram is an object that aggregates statistics, and can summarize them in |
6 // various forms, including ASCII graphical, HTML, and numerically (as a | 6 // various forms, including ASCII graphical, HTML, and numerically (as a |
7 // vector of numbers corresponding to each of the aggregating buckets). | 7 // vector of numbers corresponding to each of the aggregating buckets). |
8 | 8 |
9 // It supports calls to accumulate either time intervals (which are processed | 9 // It supports calls to accumulate either time intervals (which are processed |
10 // as integral number of milliseconds), or arbitrary integral units. | 10 // as integral number of milliseconds), or arbitrary integral units. |
11 | 11 |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 | 535 |
536 DISALLOW_COPY_AND_ASSIGN(Histogram); | 536 DISALLOW_COPY_AND_ASSIGN(Histogram); |
537 }; | 537 }; |
538 | 538 |
539 //------------------------------------------------------------------------------ | 539 //------------------------------------------------------------------------------ |
540 | 540 |
541 // LinearHistogram is a more traditional histogram, with evenly spaced | 541 // LinearHistogram is a more traditional histogram, with evenly spaced |
542 // buckets. | 542 // buckets. |
543 class LinearHistogram : public Histogram { | 543 class LinearHistogram : public Histogram { |
544 public: | 544 public: |
545 virtual ClassType histogram_type() const; | 545 virtual ~LinearHistogram(); |
546 | |
547 // Store a list of number/text values for use in rendering the histogram. | |
548 // The last element in the array has a null in its "description" slot. | |
549 virtual void SetRangeDescriptions(const DescriptionPair descriptions[]); | |
550 | 546 |
551 /* minimum should start from 1. 0 is as minimum is invalid. 0 is an implicit | 547 /* minimum should start from 1. 0 is as minimum is invalid. 0 is an implicit |
552 default underflow bucket. */ | 548 default underflow bucket. */ |
553 static scoped_refptr<Histogram> FactoryGet(const std::string& name, | 549 static scoped_refptr<Histogram> FactoryGet(const std::string& name, |
554 Sample minimum, Sample maximum, size_t bucket_count, Flags flags); | 550 Sample minimum, Sample maximum, size_t bucket_count, Flags flags); |
555 static scoped_refptr<Histogram> FactoryTimeGet(const std::string& name, | 551 static scoped_refptr<Histogram> FactoryTimeGet(const std::string& name, |
556 TimeDelta minimum, TimeDelta maximum, size_t bucket_count, | 552 TimeDelta minimum, TimeDelta maximum, size_t bucket_count, |
557 Flags flags); | 553 Flags flags); |
558 | 554 |
559 virtual ~LinearHistogram(); | 555 // Overridden from Histogram: |
| 556 virtual ClassType histogram_type() const; |
| 557 |
| 558 // Store a list of number/text values for use in rendering the histogram. |
| 559 // The last element in the array has a null in its "description" slot. |
| 560 virtual void SetRangeDescriptions(const DescriptionPair descriptions[]); |
560 | 561 |
561 protected: | 562 protected: |
562 LinearHistogram(const std::string& name, Sample minimum, | 563 LinearHistogram(const std::string& name, Sample minimum, |
563 Sample maximum, size_t bucket_count); | 564 Sample maximum, size_t bucket_count); |
564 | 565 |
565 LinearHistogram(const std::string& name, TimeDelta minimum, | 566 LinearHistogram(const std::string& name, TimeDelta minimum, |
566 TimeDelta maximum, size_t bucket_count); | 567 TimeDelta maximum, size_t bucket_count); |
567 | 568 |
568 // Initialize ranges_ mapping. | 569 // Initialize ranges_ mapping. |
569 virtual void InitializeBucketRange(); | 570 virtual void InitializeBucketRange(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 explicit BooleanHistogram(const std::string& name); | 604 explicit BooleanHistogram(const std::string& name); |
604 | 605 |
605 DISALLOW_COPY_AND_ASSIGN(BooleanHistogram); | 606 DISALLOW_COPY_AND_ASSIGN(BooleanHistogram); |
606 }; | 607 }; |
607 | 608 |
608 //------------------------------------------------------------------------------ | 609 //------------------------------------------------------------------------------ |
609 | 610 |
610 // CustomHistogram is a histogram for a set of custom integers. | 611 // CustomHistogram is a histogram for a set of custom integers. |
611 class CustomHistogram : public Histogram { | 612 class CustomHistogram : public Histogram { |
612 public: | 613 public: |
613 virtual ClassType histogram_type() const; | |
614 | 614 |
615 static scoped_refptr<Histogram> FactoryGet(const std::string& name, | 615 static scoped_refptr<Histogram> FactoryGet(const std::string& name, |
616 const std::vector<Sample>& custom_ranges, Flags flags); | 616 const std::vector<Sample>& custom_ranges, Flags flags); |
617 | 617 |
| 618 // Overridden from Histogram: |
| 619 virtual ClassType histogram_type() const; |
| 620 |
618 protected: | 621 protected: |
619 CustomHistogram(const std::string& name, | 622 CustomHistogram(const std::string& name, |
620 const std::vector<Sample>& custom_ranges); | 623 const std::vector<Sample>& custom_ranges); |
621 | 624 |
622 // Initialize ranges_ mapping. | 625 // Initialize ranges_ mapping. |
623 virtual void InitializeBucketRange(); | 626 virtual void InitializeBucketRange(); |
624 virtual double GetBucketSize(Count current, size_t i) const; | 627 virtual double GetBucketSize(Count current, size_t i) const; |
625 | 628 |
626 private: | 629 private: |
627 // Temporary pointer used during construction/initialization, and then NULLed. | 630 // Temporary pointer used during construction/initialization, and then NULLed. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 | 689 |
687 // Dump all known histograms to log. | 690 // Dump all known histograms to log. |
688 static bool dump_on_exit_; | 691 static bool dump_on_exit_; |
689 | 692 |
690 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); | 693 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); |
691 }; | 694 }; |
692 | 695 |
693 } // namespace base | 696 } // namespace base |
694 | 697 |
695 #endif // BASE_METRICS_HISTOGRAM_H_ | 698 #endif // BASE_METRICS_HISTOGRAM_H_ |
OLD | NEW |