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 23 matching lines...) Expand all Loading... | |
34 // initialization is not a problem as it is always set to point to the same | 34 // initialization is not a problem as it is always set to point to the same |
35 // value (i.e., the FactoryGet always returns the same value). FactoryGet | 35 // value (i.e., the FactoryGet always returns the same value). FactoryGet |
36 // is also completely thread safe, which results in a completely thread safe, | 36 // is also completely thread safe, which results in a completely thread safe, |
37 // and relatively fast, set of counters. To avoid races at shutdown, the static | 37 // and relatively fast, set of counters. To avoid races at shutdown, the static |
38 // pointer is NOT deleted, and we leak the histograms at process termination. | 38 // pointer is NOT deleted, and we leak the histograms at process termination. |
39 | 39 |
40 #ifndef BASE_METRICS_HISTOGRAM_H_ | 40 #ifndef BASE_METRICS_HISTOGRAM_H_ |
41 #define BASE_METRICS_HISTOGRAM_H_ | 41 #define BASE_METRICS_HISTOGRAM_H_ |
42 #pragma once | 42 #pragma once |
43 | 43 |
44 #include <list> | |
44 #include <map> | 45 #include <map> |
45 #include <string> | 46 #include <string> |
46 #include <vector> | 47 #include <vector> |
47 | 48 |
48 #include "base/atomicops.h" | 49 #include "base/atomicops.h" |
49 #include "base/base_export.h" | 50 #include "base/base_export.h" |
50 #include "base/gtest_prod_util.h" | 51 #include "base/gtest_prod_util.h" |
51 #include "base/logging.h" | 52 #include "base/logging.h" |
52 #include "base/time.h" | 53 #include "base/time.h" |
53 | 54 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 276 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
276 base::CustomHistogram::FactoryGet(name, custom_ranges, \ | 277 base::CustomHistogram::FactoryGet(name, custom_ranges, \ |
277 base::Histogram::kUmaTargetedHistogramFlag)) | 278 base::Histogram::kUmaTargetedHistogramFlag)) |
278 | 279 |
279 //------------------------------------------------------------------------------ | 280 //------------------------------------------------------------------------------ |
280 | 281 |
281 class BooleanHistogram; | 282 class BooleanHistogram; |
282 class CustomHistogram; | 283 class CustomHistogram; |
283 class Histogram; | 284 class Histogram; |
284 class LinearHistogram; | 285 class LinearHistogram; |
286 class CachedRanges; | |
jar (doing other things)
2011/10/04 22:32:38
nit: Probably alphabetize list would be nice (not
ramant (doing other things)
2011/10/19 01:09:52
Done.
| |
285 | 287 |
286 class BASE_EXPORT Histogram { | 288 class BASE_EXPORT Histogram { |
287 public: | 289 public: |
288 typedef int Sample; // Used for samples (and ranges of samples). | 290 typedef int Sample; // Used for samples (and ranges of samples). |
289 typedef int Count; // Used to count samples in a bucket. | 291 typedef int Count; // Used to count samples in a bucket. |
290 static const Sample kSampleType_MAX = INT_MAX; | 292 static const Sample kSampleType_MAX = INT_MAX; |
291 // Initialize maximum number of buckets in histograms as 16,384. | 293 // Initialize maximum number of buckets in histograms as 16,384. |
292 static const size_t kBucketCount_MAX; | 294 static const size_t kBucketCount_MAX; |
293 | 295 |
294 typedef std::vector<Count> Counts; | 296 typedef std::vector<Count> Counts; |
295 typedef std::vector<Sample> Ranges; | |
296 | 297 |
297 // These enums are used to facilitate deserialization of renderer histograms | 298 // These enums are used to facilitate deserialization of renderer histograms |
298 // into the browser. | 299 // into the browser. |
299 enum ClassType { | 300 enum ClassType { |
300 HISTOGRAM, | 301 HISTOGRAM, |
301 LINEAR_HISTOGRAM, | 302 LINEAR_HISTOGRAM, |
302 BOOLEAN_HISTOGRAM, | 303 BOOLEAN_HISTOGRAM, |
303 CUSTOM_HISTOGRAM, | 304 CUSTOM_HISTOGRAM, |
304 NOT_VALID_IN_RENDERER | 305 NOT_VALID_IN_RENDERER |
305 }; | 306 }; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 //---------------------------------------------------------------------------- | 457 //---------------------------------------------------------------------------- |
457 // Accessors for factory constuction, serialization and testing. | 458 // Accessors for factory constuction, serialization and testing. |
458 //---------------------------------------------------------------------------- | 459 //---------------------------------------------------------------------------- |
459 virtual ClassType histogram_type() const; | 460 virtual ClassType histogram_type() const; |
460 const std::string& histogram_name() const { return histogram_name_; } | 461 const std::string& histogram_name() const { return histogram_name_; } |
461 Sample declared_min() const { return declared_min_; } | 462 Sample declared_min() const { return declared_min_; } |
462 Sample declared_max() const { return declared_max_; } | 463 Sample declared_max() const { return declared_max_; } |
463 virtual Sample ranges(size_t i) const; | 464 virtual Sample ranges(size_t i) const; |
464 uint32 range_checksum() const { return range_checksum_; } | 465 uint32 range_checksum() const { return range_checksum_; } |
465 virtual size_t bucket_count() const; | 466 virtual size_t bucket_count() const; |
467 CachedRanges* cached_ranges() const { return cached_ranges_; } | |
468 void set_cached_ranges(CachedRanges* cached_ranges) { | |
469 cached_ranges_ = cached_ranges; | |
470 } | |
466 // Snapshot the current complete set of sample data. | 471 // Snapshot the current complete set of sample data. |
467 // Override with atomic/locked snapshot if needed. | 472 // Override with atomic/locked snapshot if needed. |
468 virtual void SnapshotSample(SampleSet* sample) const; | 473 virtual void SnapshotSample(SampleSet* sample) const; |
469 | 474 |
470 virtual bool HasConstructorArguments(Sample minimum, Sample maximum, | 475 virtual bool HasConstructorArguments(Sample minimum, Sample maximum, |
471 size_t bucket_count); | 476 size_t bucket_count); |
472 | 477 |
473 virtual bool HasConstructorTimeDeltaArguments(TimeDelta minimum, | 478 virtual bool HasConstructorTimeDeltaArguments(TimeDelta minimum, |
474 TimeDelta maximum, | 479 TimeDelta maximum, |
475 size_t bucket_count); | 480 size_t bucket_count); |
476 // Return true iff the range_checksum_ matches current ranges_ vector. | 481 // Return true iff the range_checksum_ matches current |ranges_| vector in |
482 // |cached_ranges_|. | |
477 bool HasValidRangeChecksum() const; | 483 bool HasValidRangeChecksum() const; |
478 | 484 |
479 protected: | 485 protected: |
480 Histogram(const std::string& name, Sample minimum, | 486 Histogram(const std::string& name, Sample minimum, |
481 Sample maximum, size_t bucket_count); | 487 Sample maximum, size_t bucket_count); |
482 Histogram(const std::string& name, TimeDelta minimum, | 488 Histogram(const std::string& name, TimeDelta minimum, |
483 TimeDelta maximum, size_t bucket_count); | 489 TimeDelta maximum, size_t bucket_count); |
484 | 490 |
485 virtual ~Histogram(); | 491 virtual ~Histogram(); |
486 | 492 |
487 // Initialize ranges_ mapping. | 493 // Initialize ranges_ mapping in cached_ranges_. |
488 void InitializeBucketRange(); | 494 void InitializeBucketRange(); |
489 | 495 |
490 // Method to override to skip the display of the i'th bucket if it's empty. | 496 // Method to override to skip the display of the i'th bucket if it's empty. |
491 virtual bool PrintEmptyBucket(size_t index) const; | 497 virtual bool PrintEmptyBucket(size_t index) const; |
492 | 498 |
493 //---------------------------------------------------------------------------- | 499 //---------------------------------------------------------------------------- |
494 // Methods to override to create histogram with different bucket widths. | 500 // Methods to override to create histogram with different bucket widths. |
495 //---------------------------------------------------------------------------- | 501 //---------------------------------------------------------------------------- |
496 // Find bucket to increment for sample value. | 502 // Find bucket to increment for sample value. |
497 virtual size_t BucketIndex(Sample value) const; | 503 virtual size_t BucketIndex(Sample value) const; |
498 // Get normalized size, relative to the ranges_[i]. | 504 // Get normalized size, relative to the ranges(i). |
499 virtual double GetBucketSize(Count current, size_t i) const; | 505 virtual double GetBucketSize(Count current, size_t i) const; |
500 | 506 |
501 // Recalculate range_checksum_. | 507 // Recalculate range_checksum_. |
502 void ResetRangeChecksum(); | 508 void ResetRangeChecksum(); |
503 | 509 |
504 // Return a string description of what goes in a given bucket. | 510 // Return a string description of what goes in a given bucket. |
505 // Most commonly this is the numeric value, but in derived classes it may | 511 // Most commonly this is the numeric value, but in derived classes it may |
506 // be a name (or string description) given to the bucket. | 512 // be a name (or string description) given to the bucket. |
507 virtual const std::string GetAsciiBucketRange(size_t it) const; | 513 virtual const std::string GetAsciiBucketRange(size_t it) const; |
508 | 514 |
509 //---------------------------------------------------------------------------- | 515 //---------------------------------------------------------------------------- |
510 // Methods to override to create thread safe histogram. | 516 // Methods to override to create thread safe histogram. |
511 //---------------------------------------------------------------------------- | 517 //---------------------------------------------------------------------------- |
512 // Update all our internal data, including histogram | 518 // Update all our internal data, including histogram |
513 virtual void Accumulate(Sample value, Count count, size_t index); | 519 virtual void Accumulate(Sample value, Count count, size_t index); |
514 | 520 |
515 //---------------------------------------------------------------------------- | 521 //---------------------------------------------------------------------------- |
516 // Accessors for derived classes. | 522 // Accessors for derived classes. |
517 //---------------------------------------------------------------------------- | 523 //---------------------------------------------------------------------------- |
518 void SetBucketRange(size_t i, Sample value); | 524 void SetBucketRange(size_t i, Sample value); |
519 | 525 |
520 // Validate that ranges_ was created sensibly (top and bottom range | 526 // Validate that ranges_ in cached_ranges_ was created sensibly (top and |
521 // values relate properly to the declared_min_ and declared_max_).. | 527 // bottom range values relate properly to the declared_min_ and |
528 // declared_max_). | |
522 bool ValidateBucketRanges() const; | 529 bool ValidateBucketRanges() const; |
523 | 530 |
524 virtual uint32 CalculateRangeChecksum() const; | 531 virtual uint32 CalculateRangeChecksum() const; |
525 | 532 |
526 private: | 533 private: |
527 // Allow tests to corrupt our innards for testing purposes. | 534 // Allow tests to corrupt our innards for testing purposes. |
528 FRIEND_TEST(HistogramTest, CorruptBucketBounds); | 535 FRIEND_TEST(HistogramTest, CorruptBucketBounds); |
529 FRIEND_TEST(HistogramTest, CorruptSampleCounts); | 536 FRIEND_TEST(HistogramTest, CorruptSampleCounts); |
530 FRIEND_TEST(HistogramTest, Crc32SampleHash); | 537 FRIEND_TEST(HistogramTest, Crc32SampleHash); |
531 FRIEND_TEST(HistogramTest, Crc32TableTest); | 538 FRIEND_TEST(HistogramTest, Crc32TableTest); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
575 Sample declared_min_; // Less than this goes into counts_[0] | 582 Sample declared_min_; // Less than this goes into counts_[0] |
576 Sample declared_max_; // Over this goes into counts_[bucket_count_ - 1]. | 583 Sample declared_max_; // Over this goes into counts_[bucket_count_ - 1]. |
577 size_t bucket_count_; // Dimension of counts_[]. | 584 size_t bucket_count_; // Dimension of counts_[]. |
578 | 585 |
579 // Flag the histogram for recording by UMA via metric_services.h. | 586 // Flag the histogram for recording by UMA via metric_services.h. |
580 Flags flags_; | 587 Flags flags_; |
581 | 588 |
582 // For each index, show the least value that can be stored in the | 589 // For each index, show the least value that can be stored in the |
583 // corresponding bucket. We also append one extra element in this array, | 590 // corresponding bucket. We also append one extra element in this array, |
584 // containing kSampleType_MAX, to make calculations easy. | 591 // containing kSampleType_MAX, to make calculations easy. |
585 // The dimension of ranges_ is bucket_count + 1. | 592 // The dimension of ranges_ in cached_ranges_ is bucket_count + 1. |
586 Ranges ranges_; | 593 CachedRanges* cached_ranges_; |
587 | 594 |
588 // For redundancy, we store a checksum of all the sample ranges when ranges | 595 // For redundancy, we store a checksum of all the sample ranges when ranges |
589 // are generated. If ever there is ever a difference, then the histogram must | 596 // are generated. If ever there is ever a difference, then the histogram must |
590 // have been corrupted. | 597 // have been corrupted. |
591 uint32 range_checksum_; | 598 uint32 range_checksum_; |
592 | 599 |
593 // Finally, provide the state that changes with the addition of each new | 600 // Finally, provide the state that changes with the addition of each new |
594 // sample. | 601 // sample. |
595 SampleSet sample_; | 602 SampleSet sample_; |
596 | 603 |
(...skipping 28 matching lines...) Expand all Loading... | |
625 // The last element in the array has a null in its "description" slot. | 632 // The last element in the array has a null in its "description" slot. |
626 virtual void SetRangeDescriptions(const DescriptionPair descriptions[]); | 633 virtual void SetRangeDescriptions(const DescriptionPair descriptions[]); |
627 | 634 |
628 protected: | 635 protected: |
629 LinearHistogram(const std::string& name, Sample minimum, | 636 LinearHistogram(const std::string& name, Sample minimum, |
630 Sample maximum, size_t bucket_count); | 637 Sample maximum, size_t bucket_count); |
631 | 638 |
632 LinearHistogram(const std::string& name, TimeDelta minimum, | 639 LinearHistogram(const std::string& name, TimeDelta minimum, |
633 TimeDelta maximum, size_t bucket_count); | 640 TimeDelta maximum, size_t bucket_count); |
634 | 641 |
635 // Initialize ranges_ mapping. | 642 // Initialize ranges_ mapping in cached_ranges_. |
636 void InitializeBucketRange(); | 643 void InitializeBucketRange(); |
637 virtual double GetBucketSize(Count current, size_t i) const; | 644 virtual double GetBucketSize(Count current, size_t i) const; |
638 | 645 |
639 // If we have a description for a bucket, then return that. Otherwise | 646 // If we have a description for a bucket, then return that. Otherwise |
640 // let parent class provide a (numeric) description. | 647 // let parent class provide a (numeric) description. |
641 virtual const std::string GetAsciiBucketRange(size_t i) const; | 648 virtual const std::string GetAsciiBucketRange(size_t i) const; |
642 | 649 |
643 // Skip printing of name for numeric range if we have a name (and if this is | 650 // Skip printing of name for numeric range if we have a name (and if this is |
644 // an empty bucket). | 651 // an empty bucket). |
645 virtual bool PrintEmptyBucket(size_t index) const; | 652 virtual bool PrintEmptyBucket(size_t index) const; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
689 // This function ensures that a guard bucket exists right after any | 696 // This function ensures that a guard bucket exists right after any |
690 // valid sample value (unless the next higher sample is also a valid value), | 697 // valid sample value (unless the next higher sample is also a valid value), |
691 // so that invalid samples never fall into the same bucket as valid samples. | 698 // so that invalid samples never fall into the same bucket as valid samples. |
692 static std::vector<Sample> ArrayToCustomRanges(const Sample* values, | 699 static std::vector<Sample> ArrayToCustomRanges(const Sample* values, |
693 size_t num_values); | 700 size_t num_values); |
694 | 701 |
695 protected: | 702 protected: |
696 CustomHistogram(const std::string& name, | 703 CustomHistogram(const std::string& name, |
697 const std::vector<Sample>& custom_ranges); | 704 const std::vector<Sample>& custom_ranges); |
698 | 705 |
699 // Initialize ranges_ mapping. | 706 // Initialize ranges_ mapping in cached_ranges_. |
700 void InitializedCustomBucketRange(const std::vector<Sample>& custom_ranges); | 707 void InitializedCustomBucketRange(const std::vector<Sample>& custom_ranges); |
701 virtual double GetBucketSize(Count current, size_t i) const; | 708 virtual double GetBucketSize(Count current, size_t i) const; |
702 | 709 |
703 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); | 710 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); |
704 }; | 711 }; |
705 | 712 |
706 //------------------------------------------------------------------------------ | 713 //------------------------------------------------------------------------------ |
707 // StatisticsRecorder handles all histograms in the system. It provides a | 714 // StatisticsRecorder handles all histograms in the system. It provides a |
708 // general place for histograms to register, and supports a global API for | 715 // general place for histograms to register, and supports a global API for |
709 // accessing (i.e., dumping, or graphing) the data in all the histograms. | 716 // accessing (i.e., dumping, or graphing) the data in all the histograms. |
710 | 717 |
711 class BASE_EXPORT StatisticsRecorder { | 718 class BASE_EXPORT StatisticsRecorder { |
712 public: | 719 public: |
713 typedef std::vector<Histogram*> Histograms; | 720 typedef std::vector<Histogram*> Histograms; |
714 | 721 |
715 StatisticsRecorder(); | 722 StatisticsRecorder(); |
716 | 723 |
717 ~StatisticsRecorder(); | 724 ~StatisticsRecorder(); |
718 | 725 |
719 // Find out if histograms can now be registered into our list. | 726 // Find out if histograms can now be registered into our list. |
720 static bool IsActive(); | 727 static bool IsActive(); |
721 | 728 |
722 // Register, or add a new histogram to the collection of statistics. If an | 729 // Register, or add a new histogram to the collection of statistics. If an |
723 // identically named histogram is already registered, then the argument | 730 // identically named histogram is already registered, then the argument |
724 // |histogram| will deleted. The returned value is always the registered | 731 // |histogram| will deleted. The returned value is always the registered |
725 // histogram (either the argument, or the pre-existing registered histogram). | 732 // histogram (either the argument, or the pre-existing registered histogram). |
726 static Histogram* RegisterOrDeleteDuplicate(Histogram* histogram); | 733 static Histogram* RegisterOrDeleteDuplicate(Histogram* histogram); |
727 | 734 |
735 // Register, or add a new cached_ranges_ of |histogram|. If an identical | |
736 // cached_ranges_ is already registered, then the cached_ranges_ of | |
737 // |histogram| is deleted and the |histogram|'s cached_ranges_ is reset to the | |
738 // registered cached_ranges_. The cached_ranges_ of |histogram| is always the | |
739 // registered CachedRanges (either the argument's cached_ranges_, or the | |
740 // pre-existing registered cached_ranges_). | |
741 static void RegisterOrDeleteDuplicateRanges(Histogram* histogram); | |
742 | |
743 // Method for collecting stats about histograms created in browser and | |
744 // renderer processes. |suffix| is appended to histogram names. |suffix| could | |
745 // be either browser or renderer. | |
746 static void CollectHistogramStats(const std::string& suffix); | |
747 | |
728 // Methods for printing histograms. Only histograms which have query as | 748 // Methods for printing histograms. Only histograms which have query as |
729 // a substring are written to output (an empty string will process all | 749 // a substring are written to output (an empty string will process all |
730 // registered histograms). | 750 // registered histograms). |
731 static void WriteHTMLGraph(const std::string& query, std::string* output); | 751 static void WriteHTMLGraph(const std::string& query, std::string* output); |
732 static void WriteGraph(const std::string& query, std::string* output); | 752 static void WriteGraph(const std::string& query, std::string* output); |
733 | 753 |
734 // Method for extracting histograms which were marked for use by UMA. | 754 // Method for extracting histograms which were marked for use by UMA. |
735 static void GetHistograms(Histograms* output); | 755 static void GetHistograms(Histograms* output); |
736 | 756 |
737 // Find a histogram by name. It matches the exact name. This method is thread | 757 // Find a histogram by name. It matches the exact name. This method is thread |
738 // safe. If a matching histogram is not found, then the |histogram| is | 758 // safe. If a matching histogram is not found, then the |histogram| is |
739 // not changed. | 759 // not changed. |
740 static bool FindHistogram(const std::string& query, Histogram** histogram); | 760 static bool FindHistogram(const std::string& query, Histogram** histogram); |
741 | 761 |
742 static bool dump_on_exit() { return dump_on_exit_; } | 762 static bool dump_on_exit() { return dump_on_exit_; } |
743 | 763 |
744 static void set_dump_on_exit(bool enable) { dump_on_exit_ = enable; } | 764 static void set_dump_on_exit(bool enable) { dump_on_exit_ = enable; } |
745 | 765 |
746 // GetSnapshot copies some of the pointers to registered histograms into the | 766 // GetSnapshot copies some of the pointers to registered histograms into the |
747 // caller supplied vector (Histograms). Only histograms with names matching | 767 // caller supplied vector (Histograms). Only histograms with names matching |
748 // query are returned. The query must be a substring of histogram name for its | 768 // query are returned. The query must be a substring of histogram name for its |
749 // pointer to be copied. | 769 // pointer to be copied. |
750 static void GetSnapshot(const std::string& query, Histograms* snapshot); | 770 static void GetSnapshot(const std::string& query, Histograms* snapshot); |
751 | 771 |
752 | 772 |
753 private: | 773 private: |
754 // We keep all registered histograms in a map, from name to histogram. | 774 // We keep all registered histograms in a map, from name to histogram. |
755 typedef std::map<std::string, Histogram*> HistogramMap; | 775 typedef std::map<std::string, Histogram*> HistogramMap; |
756 | 776 |
777 // We keep all |cached_ranges_| in a map, from checksum to a list of | |
778 // |cached_ranges_|. Checksum is calculated from the |ranges_| in | |
779 // |cached_ranges_|. | |
780 typedef std::map<uint32, std::list<CachedRanges*>*> RangesMap; | |
781 | |
757 static HistogramMap* histograms_; | 782 static HistogramMap* histograms_; |
758 | 783 |
784 static RangesMap* ranges_; | |
785 | |
759 // lock protects access to the above map. | 786 // lock protects access to the above map. |
760 static base::Lock* lock_; | 787 static base::Lock* lock_; |
761 | 788 |
762 // Dump all known histograms to log. | 789 // Dump all known histograms to log. |
763 static bool dump_on_exit_; | 790 static bool dump_on_exit_; |
764 | 791 |
765 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); | 792 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); |
766 }; | 793 }; |
767 | 794 |
795 //------------------------------------------------------------------------------ | |
796 | |
797 // CachedRanges stores the Ranges vector. Histograms that have same Ranges | |
798 // vector will use the same CachedRanges object. | |
799 class BASE_EXPORT CachedRanges { | |
800 public: | |
801 typedef std::vector<Histogram::Sample> Ranges; | |
802 | |
803 CachedRanges(size_t bucket_count, int initial_value); | |
804 ~CachedRanges(); | |
805 | |
806 //---------------------------------------------------------------------------- | |
807 // Accessors methods for ranges_ and range_checksum_. | |
808 //---------------------------------------------------------------------------- | |
809 size_t size() const { return ranges_.size(); } | |
810 Histogram::Sample ranges(size_t i) const { return ranges_[i]; } | |
811 void SetBucketRange(size_t i, Histogram::Sample value); | |
812 uint32 range_checksum(uint32 checksum) const { return range_checksum_; } | |
813 void SetRangeChecksum(uint32 checksum) { range_checksum_ = checksum; } | |
814 | |
815 // Return true iff |other| object has same ranges_ as |this| object's ranges_. | |
816 bool Equals(CachedRanges* other) const; | |
817 | |
818 private: | |
819 // Allow tests to corrupt our innards for testing purposes. | |
820 FRIEND_TEST(HistogramTest, CorruptBucketBounds); | |
821 | |
822 // For each index, show the least value that can be stored in the | |
jar (doing other things)
2011/10/04 22:32:38
nit: Suggest changing comment to:
A monotonically
ramant (doing other things)
2011/10/19 01:09:52
Done.
| |
823 // corresponding bucket. | |
824 Ranges ranges_; | |
825 | |
826 // |range_checksum_| is a checksum of all the sample in ranges_ vector. | |
jar (doing other things)
2011/10/04 22:32:38
nit: Suggest changing comment to:
Checksum for the
ramant (doing other things)
2011/10/19 01:09:52
Done.
| |
827 uint32 range_checksum_; | |
828 | |
829 DISALLOW_COPY_AND_ASSIGN(CachedRanges); | |
830 }; | |
831 | |
768 } // namespace base | 832 } // namespace base |
769 | 833 |
770 #endif // BASE_METRICS_HISTOGRAM_H_ | 834 #endif // BASE_METRICS_HISTOGRAM_H_ |
OLD | NEW |