Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 //---------------------------------------------------------------------------- | 378 //---------------------------------------------------------------------------- |
| 379 // For a valid histogram, input should follow these restrictions: | 379 // For a valid histogram, input should follow these restrictions: |
| 380 // minimum > 0 (if a minimum below 1 is specified, it will implicitly be | 380 // minimum > 0 (if a minimum below 1 is specified, it will implicitly be |
| 381 // normalized up to 1) | 381 // normalized up to 1) |
| 382 // maximum > minimum | 382 // maximum > minimum |
| 383 // buckets > 2 [minimum buckets needed: underflow, overflow and the range] | 383 // buckets > 2 [minimum buckets needed: underflow, overflow and the range] |
| 384 // Additionally, | 384 // Additionally, |
| 385 // buckets <= (maximum - minimum + 2) - this is to ensure that we don't have | 385 // buckets <= (maximum - minimum + 2) - this is to ensure that we don't have |
| 386 // more buckets than the range of numbers; having more buckets than 1 per | 386 // more buckets than the range of numbers; having more buckets than 1 per |
| 387 // value in the range would be nonsensical. | 387 // value in the range would be nonsensical. |
| 388 static HistogramBase* FactoryGet(const std::string& name, | 388 static HistogramBase* FactoryGet( |
| 389 Sample minimum, | 389 const std::string& name, |
| 390 Sample maximum, | 390 Sample minimum, |
| 391 size_t bucket_count, | 391 Sample maximum, |
| 392 int32 flags); | 392 size_t bucket_count, |
| 393 static HistogramBase* FactoryTimeGet(const std::string& name, | 393 int32 flags, |
| 394 base::TimeDelta minimum, | 394 int32 construction_behavior = kDoNotAllowBadConstruction); |
|
jar (doing other things)
2014/01/24 16:15:09
Sadly, this is a violation of the style guide.
Pe
elijahtaylor1
2014/01/24 20:37:22
If allowing NULL dereference is ok for what we're
| |
| 395 base::TimeDelta maximum, | 395 static HistogramBase* FactoryTimeGet( |
| 396 size_t bucket_count, | 396 const std::string& name, |
| 397 int32 flags); | 397 base::TimeDelta minimum, |
| 398 base::TimeDelta maximum, | |
| 399 size_t bucket_count, | |
| 400 int32 flags, | |
| 401 int32 construction_behavior = kDoNotAllowBadConstruction); | |
| 398 | 402 |
| 399 // Time call for use with DHISTOGRAM*. | 403 // Time call for use with DHISTOGRAM*. |
| 400 // Returns TimeTicks::Now() in debug and TimeTicks() in release build. | 404 // Returns TimeTicks::Now() in debug and TimeTicks() in release build. |
| 401 static TimeTicks DebugNow(); | 405 static TimeTicks DebugNow(); |
| 402 | 406 |
| 403 static void InitializeBucketRanges(Sample minimum, | 407 static void InitializeBucketRanges(Sample minimum, |
| 404 Sample maximum, | 408 Sample maximum, |
| 405 BucketRanges* ranges); | 409 BucketRanges* ranges); |
| 406 | 410 |
| 407 // This constant if for FindCorruption. Since snapshots of histograms are | 411 // This constant if for FindCorruption. Since snapshots of histograms are |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 //------------------------------------------------------------------------------ | 543 //------------------------------------------------------------------------------ |
| 540 | 544 |
| 541 // LinearHistogram is a more traditional histogram, with evenly spaced | 545 // LinearHistogram is a more traditional histogram, with evenly spaced |
| 542 // buckets. | 546 // buckets. |
| 543 class BASE_EXPORT LinearHistogram : public Histogram { | 547 class BASE_EXPORT LinearHistogram : public Histogram { |
| 544 public: | 548 public: |
| 545 virtual ~LinearHistogram(); | 549 virtual ~LinearHistogram(); |
| 546 | 550 |
| 547 /* minimum should start from 1. 0 is as minimum is invalid. 0 is an implicit | 551 /* minimum should start from 1. 0 is as minimum is invalid. 0 is an implicit |
| 548 default underflow bucket. */ | 552 default underflow bucket. */ |
| 549 static HistogramBase* FactoryGet(const std::string& name, | 553 static HistogramBase* FactoryGet( |
| 550 Sample minimum, | 554 const std::string& name, |
| 551 Sample maximum, | 555 Sample minimum, |
| 552 size_t bucket_count, | 556 Sample maximum, |
| 553 int32 flags); | 557 size_t bucket_count, |
| 558 int32 flags, | |
| 559 int32 construction_behavior = kDoNotAllowBadConstruction); | |
| 554 static HistogramBase* FactoryTimeGet(const std::string& name, | 560 static HistogramBase* FactoryTimeGet(const std::string& name, |
| 555 TimeDelta minimum, | 561 TimeDelta minimum, |
| 556 TimeDelta maximum, | 562 TimeDelta maximum, |
| 557 size_t bucket_count, | 563 size_t bucket_count, |
| 558 int32 flags); | 564 int32 flags, |
| 565 int32 construction_behavior = kDoNotAllowBadConstruction); | |
| 559 | 566 |
| 560 struct DescriptionPair { | 567 struct DescriptionPair { |
| 561 Sample sample; | 568 Sample sample; |
| 562 const char* description; // Null means end of a list of pairs. | 569 const char* description; // Null means end of a list of pairs. |
| 563 }; | 570 }; |
| 564 | 571 |
| 565 // Create a LinearHistogram and store a list of number/text values for use in | 572 // Create a LinearHistogram and store a list of number/text values for use in |
| 566 // writing the histogram graph. | 573 // writing the histogram graph. |
| 567 // |descriptions| can be NULL, which means no special descriptions to set. If | 574 // |descriptions| can be NULL, which means no special descriptions to set. If |
| 568 // it's not NULL, the last element in the array must has a NULL in its | 575 // it's not NULL, the last element in the array must has a NULL in its |
| 569 // "description" field. | 576 // "description" field. |
| 570 static HistogramBase* FactoryGetWithRangeDescription( | 577 static HistogramBase* FactoryGetWithRangeDescription( |
| 571 const std::string& name, | 578 const std::string& name, |
| 572 Sample minimum, | 579 Sample minimum, |
| 573 Sample maximum, | 580 Sample maximum, |
| 574 size_t bucket_count, | 581 size_t bucket_count, |
| 575 int32 flags, | 582 int32 flags, |
| 576 const DescriptionPair descriptions[]); | 583 const DescriptionPair descriptions[], |
| 584 int32 construction_behavior = kDoNotAllowBadConstruction); | |
| 577 | 585 |
| 578 static void InitializeBucketRanges(Sample minimum, | 586 static void InitializeBucketRanges(Sample minimum, |
| 579 Sample maximum, | 587 Sample maximum, |
| 580 BucketRanges* ranges); | 588 BucketRanges* ranges); |
| 581 | 589 |
| 582 // Overridden from Histogram: | 590 // Overridden from Histogram: |
| 583 virtual HistogramType GetHistogramType() const OVERRIDE; | 591 virtual HistogramType GetHistogramType() const OVERRIDE; |
| 584 | 592 |
| 585 protected: | 593 protected: |
| 586 LinearHistogram(const std::string& name, | 594 LinearHistogram(const std::string& name, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 672 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); | 680 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); |
| 673 static BucketRanges* CreateBucketRangesFromCustomRanges( | 681 static BucketRanges* CreateBucketRangesFromCustomRanges( |
| 674 const std::vector<Sample>& custom_ranges); | 682 const std::vector<Sample>& custom_ranges); |
| 675 | 683 |
| 676 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); | 684 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); |
| 677 }; | 685 }; |
| 678 | 686 |
| 679 } // namespace base | 687 } // namespace base |
| 680 | 688 |
| 681 #endif // BASE_METRICS_HISTOGRAM_H_ | 689 #endif // BASE_METRICS_HISTOGRAM_H_ |
| OLD | NEW |