| OLD | NEW |
| 1 // Copyright (c) 2011 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. |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 | 428 |
| 429 protected: | 429 protected: |
| 430 friend class base::RefCountedThreadSafe<Histogram>; | 430 friend class base::RefCountedThreadSafe<Histogram>; |
| 431 Histogram(const std::string& name, Sample minimum, | 431 Histogram(const std::string& name, Sample minimum, |
| 432 Sample maximum, size_t bucket_count); | 432 Sample maximum, size_t bucket_count); |
| 433 Histogram(const std::string& name, TimeDelta minimum, | 433 Histogram(const std::string& name, TimeDelta minimum, |
| 434 TimeDelta maximum, size_t bucket_count); | 434 TimeDelta maximum, size_t bucket_count); |
| 435 | 435 |
| 436 virtual ~Histogram(); | 436 virtual ~Histogram(); |
| 437 | 437 |
| 438 // Initialize ranges_ mapping. |
| 439 void InitializeBucketRange(); |
| 440 |
| 438 // Method to override to skip the display of the i'th bucket if it's empty. | 441 // Method to override to skip the display of the i'th bucket if it's empty. |
| 439 virtual bool PrintEmptyBucket(size_t index) const; | 442 virtual bool PrintEmptyBucket(size_t index) const; |
| 440 | 443 |
| 441 //---------------------------------------------------------------------------- | 444 //---------------------------------------------------------------------------- |
| 442 // Methods to override to create histogram with different bucket widths. | 445 // Methods to override to create histogram with different bucket widths. |
| 443 //---------------------------------------------------------------------------- | 446 //---------------------------------------------------------------------------- |
| 444 // Initialize ranges_ mapping. | |
| 445 virtual void InitializeBucketRange(); | |
| 446 // Find bucket to increment for sample value. | 447 // Find bucket to increment for sample value. |
| 447 virtual size_t BucketIndex(Sample value) const; | 448 virtual size_t BucketIndex(Sample value) const; |
| 448 // Get normalized size, relative to the ranges_[i]. | 449 // Get normalized size, relative to the ranges_[i]. |
| 449 virtual double GetBucketSize(Count current, size_t i) const; | 450 virtual double GetBucketSize(Count current, size_t i) const; |
| 450 | 451 |
| 451 // Recalculate range_checksum_. | 452 // Recalculate range_checksum_. |
| 452 void ResetRangeChecksum(); | 453 void ResetRangeChecksum(); |
| 453 | 454 |
| 454 // Return a string description of what goes in a given bucket. | 455 // Return a string description of what goes in a given bucket. |
| 455 // Most commonly this is the numeric value, but in derived classes it may | 456 // Most commonly this is the numeric value, but in derived classes it may |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 virtual void SetRangeDescriptions(const DescriptionPair descriptions[]); | 570 virtual void SetRangeDescriptions(const DescriptionPair descriptions[]); |
| 570 | 571 |
| 571 protected: | 572 protected: |
| 572 LinearHistogram(const std::string& name, Sample minimum, | 573 LinearHistogram(const std::string& name, Sample minimum, |
| 573 Sample maximum, size_t bucket_count); | 574 Sample maximum, size_t bucket_count); |
| 574 | 575 |
| 575 LinearHistogram(const std::string& name, TimeDelta minimum, | 576 LinearHistogram(const std::string& name, TimeDelta minimum, |
| 576 TimeDelta maximum, size_t bucket_count); | 577 TimeDelta maximum, size_t bucket_count); |
| 577 | 578 |
| 578 // Initialize ranges_ mapping. | 579 // Initialize ranges_ mapping. |
| 579 virtual void InitializeBucketRange(); | 580 void InitializeBucketRange(); |
| 580 virtual double GetBucketSize(Count current, size_t i) const; | 581 virtual double GetBucketSize(Count current, size_t i) const; |
| 581 | 582 |
| 582 // If we have a description for a bucket, then return that. Otherwise | 583 // If we have a description for a bucket, then return that. Otherwise |
| 583 // let parent class provide a (numeric) description. | 584 // let parent class provide a (numeric) description. |
| 584 virtual const std::string GetAsciiBucketRange(size_t i) const; | 585 virtual const std::string GetAsciiBucketRange(size_t i) const; |
| 585 | 586 |
| 586 // Skip printing of name for numeric range if we have a name (and if this is | 587 // Skip printing of name for numeric range if we have a name (and if this is |
| 587 // an empty bucket). | 588 // an empty bucket). |
| 588 virtual bool PrintEmptyBucket(size_t index) const; | 589 virtual bool PrintEmptyBucket(size_t index) const; |
| 589 | 590 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 | 650 |
| 650 StatisticsRecorder(); | 651 StatisticsRecorder(); |
| 651 | 652 |
| 652 ~StatisticsRecorder(); | 653 ~StatisticsRecorder(); |
| 653 | 654 |
| 654 // Find out if histograms can now be registered into our list. | 655 // Find out if histograms can now be registered into our list. |
| 655 static bool IsActive(); | 656 static bool IsActive(); |
| 656 | 657 |
| 657 // Register, or add a new histogram to the collection of statistics. If an | 658 // Register, or add a new histogram to the collection of statistics. If an |
| 658 // identically named histogram is already registered, then the argument | 659 // identically named histogram is already registered, then the argument |
| 659 // |histogram| will be replaced by the previously registered value. | 660 // |histogram| will be replaced by the previously registered value, discarding |
| 660 static void Register(scoped_refptr<Histogram>* histogram); | 661 // the referenced argument. |
| 662 static void RegisterOrDiscardDuplicate(scoped_refptr<Histogram>* histogram); |
| 661 | 663 |
| 662 // Methods for printing histograms. Only histograms which have query as | 664 // Methods for printing histograms. Only histograms which have query as |
| 663 // a substring are written to output (an empty string will process all | 665 // a substring are written to output (an empty string will process all |
| 664 // registered histograms). | 666 // registered histograms). |
| 665 static void WriteHTMLGraph(const std::string& query, std::string* output); | 667 static void WriteHTMLGraph(const std::string& query, std::string* output); |
| 666 static void WriteGraph(const std::string& query, std::string* output); | 668 static void WriteGraph(const std::string& query, std::string* output); |
| 667 | 669 |
| 668 // Method for extracting histograms which were marked for use by UMA. | 670 // Method for extracting histograms which were marked for use by UMA. |
| 669 static void GetHistograms(Histograms* output); | 671 static void GetHistograms(Histograms* output); |
| 670 | 672 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 696 | 698 |
| 697 // Dump all known histograms to log. | 699 // Dump all known histograms to log. |
| 698 static bool dump_on_exit_; | 700 static bool dump_on_exit_; |
| 699 | 701 |
| 700 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); | 702 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); |
| 701 }; | 703 }; |
| 702 | 704 |
| 703 } // namespace base | 705 } // namespace base |
| 704 | 706 |
| 705 #endif // BASE_METRICS_HISTOGRAM_H_ | 707 #endif // BASE_METRICS_HISTOGRAM_H_ |
| OLD | NEW |