Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1060)

Side by Side Diff: base/metrics/histogram.h

Issue 17451016: [UMA] Remove redundant bucket_count variable from base::Histogram. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename variables to be clearer Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/metrics/bucket_ranges_unittest.cc ('k') | base/metrics/histogram.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 base::TimeDelta maximum, 389 base::TimeDelta maximum,
390 size_t bucket_count, 390 size_t bucket_count,
391 int32 flags); 391 int32 flags);
392 392
393 // Time call for use with DHISTOGRAM*. 393 // Time call for use with DHISTOGRAM*.
394 // Returns TimeTicks::Now() in debug and TimeTicks() in release build. 394 // Returns TimeTicks::Now() in debug and TimeTicks() in release build.
395 static TimeTicks DebugNow(); 395 static TimeTicks DebugNow();
396 396
397 static void InitializeBucketRanges(Sample minimum, 397 static void InitializeBucketRanges(Sample minimum,
398 Sample maximum, 398 Sample maximum,
399 size_t bucket_count,
400 BucketRanges* ranges); 399 BucketRanges* ranges);
401 400
402 // This constant if for FindCorruption. Since snapshots of histograms are 401 // This constant if for FindCorruption. Since snapshots of histograms are
403 // taken asynchronously relative to sampling, and our counting code currently 402 // taken asynchronously relative to sampling, and our counting code currently
404 // does not prevent race conditions, it is pretty likely that we'll catch a 403 // does not prevent race conditions, it is pretty likely that we'll catch a
405 // redundant count that doesn't match the sample count. We allow for a 404 // redundant count that doesn't match the sample count. We allow for a
406 // certain amount of slop before flagging this as an inconsistency. Even with 405 // certain amount of slop before flagging this as an inconsistency. Even with
407 // an inconsistency, we'll snapshot it again (for UMA in about a half hour), 406 // an inconsistency, we'll snapshot it again (for UMA in about a half hour),
408 // so we'll eventually get the data, if it was not the result of a corruption. 407 // so we'll eventually get the data, if it was not the result of a corruption.
409 static const int kCommonRaceBasedCountMismatch; 408 static const int kCommonRaceBasedCountMismatch;
(...skipping 20 matching lines...) Expand all
430 // converts it to good input: 1. 429 // converts it to good input: 1.
431 // TODO(kaiwang): Be more restrict and return false for any bad input, and 430 // TODO(kaiwang): Be more restrict and return false for any bad input, and
432 // make this a readonly validating function. 431 // make this a readonly validating function.
433 static bool InspectConstructionArguments(const std::string& name, 432 static bool InspectConstructionArguments(const std::string& name,
434 Sample* minimum, 433 Sample* minimum,
435 Sample* maximum, 434 Sample* maximum,
436 size_t* bucket_count); 435 size_t* bucket_count);
437 436
438 // HistogramBase implementation: 437 // HistogramBase implementation:
439 virtual HistogramType GetHistogramType() const OVERRIDE; 438 virtual HistogramType GetHistogramType() const OVERRIDE;
440 virtual bool HasConstructionArguments(Sample minimum, 439 virtual bool HasConstructionArguments(
441 Sample maximum, 440 Sample expected_minimum,
442 size_t bucket_count) const OVERRIDE; 441 Sample expected_maximum,
442 size_t expected_bucket_count) const OVERRIDE;
443 virtual void Add(Sample value) OVERRIDE; 443 virtual void Add(Sample value) OVERRIDE;
444 virtual scoped_ptr<HistogramSamples> SnapshotSamples() const OVERRIDE; 444 virtual scoped_ptr<HistogramSamples> SnapshotSamples() const OVERRIDE;
445 virtual void AddSamples(const HistogramSamples& samples) OVERRIDE; 445 virtual void AddSamples(const HistogramSamples& samples) OVERRIDE;
446 virtual bool AddSamplesFromPickle(PickleIterator* iter) OVERRIDE; 446 virtual bool AddSamplesFromPickle(PickleIterator* iter) OVERRIDE;
447 virtual void WriteHTMLGraph(std::string* output) const OVERRIDE; 447 virtual void WriteHTMLGraph(std::string* output) const OVERRIDE;
448 virtual void WriteAscii(std::string* output) const OVERRIDE; 448 virtual void WriteAscii(std::string* output) const OVERRIDE;
449 449
450 protected: 450 protected:
451 // |bucket_count| and |ranges| should contain the underflow and overflow 451 // |ranges| should contain the underflow and overflow buckets. See top
452 // buckets. See top comments for example. 452 // comments for example.
453 Histogram(const std::string& name, 453 Histogram(const std::string& name,
454 Sample minimum, 454 Sample minimum,
455 Sample maximum, 455 Sample maximum,
456 size_t bucket_count,
457 const BucketRanges* ranges); 456 const BucketRanges* ranges);
458 457
459 virtual ~Histogram(); 458 virtual ~Histogram();
460 459
461 // HistogramBase implementation: 460 // HistogramBase implementation:
462 virtual bool SerializeInfoImpl(Pickle* pickle) const OVERRIDE; 461 virtual bool SerializeInfoImpl(Pickle* pickle) const OVERRIDE;
463 462
464 // Method to override to skip the display of the i'th bucket if it's empty. 463 // Method to override to skip the display of the i'th bucket if it's empty.
465 virtual bool PrintEmptyBucket(size_t index) const; 464 virtual bool PrintEmptyBucket(size_t index) const;
466 465
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 // WriteJSON calls these. 513 // WriteJSON calls these.
515 virtual void GetParameters(DictionaryValue* params) const OVERRIDE; 514 virtual void GetParameters(DictionaryValue* params) const OVERRIDE;
516 515
517 virtual void GetCountAndBucketData(Count* count, 516 virtual void GetCountAndBucketData(Count* count,
518 int64* sum, 517 int64* sum,
519 ListValue* buckets) const OVERRIDE; 518 ListValue* buckets) const OVERRIDE;
520 519
521 // Does not own this object. Should get from StatisticsRecorder. 520 // Does not own this object. Should get from StatisticsRecorder.
522 const BucketRanges* bucket_ranges_; 521 const BucketRanges* bucket_ranges_;
523 522
524 Sample declared_min_; // Less than this goes into counts_[0] 523 Sample declared_min_; // Less than this goes into the first bucket.
525 Sample declared_max_; // Over this goes into counts_[bucket_count_ - 1]. 524 Sample declared_max_; // Over this goes into the last bucket.
526 size_t bucket_count_; // Dimension of counts_[].
527 525
528 // Finally, provide the state that changes with the addition of each new 526 // Finally, provide the state that changes with the addition of each new
529 // sample. 527 // sample.
530 scoped_ptr<SampleVector> samples_; 528 scoped_ptr<SampleVector> samples_;
531 529
532 DISALLOW_COPY_AND_ASSIGN(Histogram); 530 DISALLOW_COPY_AND_ASSIGN(Histogram);
533 }; 531 };
534 532
535 //------------------------------------------------------------------------------ 533 //------------------------------------------------------------------------------
536 534
(...skipping 29 matching lines...) Expand all
566 static HistogramBase* FactoryGetWithRangeDescription( 564 static HistogramBase* FactoryGetWithRangeDescription(
567 const std::string& name, 565 const std::string& name,
568 Sample minimum, 566 Sample minimum,
569 Sample maximum, 567 Sample maximum,
570 size_t bucket_count, 568 size_t bucket_count,
571 int32 flags, 569 int32 flags,
572 const DescriptionPair descriptions[]); 570 const DescriptionPair descriptions[]);
573 571
574 static void InitializeBucketRanges(Sample minimum, 572 static void InitializeBucketRanges(Sample minimum,
575 Sample maximum, 573 Sample maximum,
576 size_t bucket_count,
577 BucketRanges* ranges); 574 BucketRanges* ranges);
578 575
579 // Overridden from Histogram: 576 // Overridden from Histogram:
580 virtual HistogramType GetHistogramType() const OVERRIDE; 577 virtual HistogramType GetHistogramType() const OVERRIDE;
581 578
582 protected: 579 protected:
583 LinearHistogram(const std::string& name, 580 LinearHistogram(const std::string& name,
584 Sample minimum, 581 Sample minimum,
585 Sample maximum, 582 Sample maximum,
586 size_t bucket_count,
587 const BucketRanges* ranges); 583 const BucketRanges* ranges);
588 584
589 virtual double GetBucketSize(Count current, size_t i) const OVERRIDE; 585 virtual double GetBucketSize(Count current, size_t i) const OVERRIDE;
590 586
591 // If we have a description for a bucket, then return that. Otherwise 587 // If we have a description for a bucket, then return that. Otherwise
592 // let parent class provide a (numeric) description. 588 // let parent class provide a (numeric) description.
593 virtual const std::string GetAsciiBucketRange(size_t i) const OVERRIDE; 589 virtual const std::string GetAsciiBucketRange(size_t i) const OVERRIDE;
594 590
595 // Skip printing of name for numeric range if we have a name (and if this is 591 // Skip printing of name for numeric range if we have a name (and if this is
596 // an empty bucket). 592 // an empty bucket).
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); 666 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges);
671 static BucketRanges* CreateBucketRangesFromCustomRanges( 667 static BucketRanges* CreateBucketRangesFromCustomRanges(
672 const std::vector<Sample>& custom_ranges); 668 const std::vector<Sample>& custom_ranges);
673 669
674 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); 670 DISALLOW_COPY_AND_ASSIGN(CustomHistogram);
675 }; 671 };
676 672
677 } // namespace base 673 } // namespace base
678 674
679 #endif // BASE_METRICS_HISTOGRAM_H_ 675 #endif // BASE_METRICS_HISTOGRAM_H_
OLDNEW
« no previous file with comments | « base/metrics/bucket_ranges_unittest.cc ('k') | base/metrics/histogram.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698