OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // See header file for details and examples. | 8 // See header file for details and examples. |
9 | 9 |
10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 //------------------------------------------------------------------------------ | 496 //------------------------------------------------------------------------------ |
497 // Methods for the Histogram::SampleSet class | 497 // Methods for the Histogram::SampleSet class |
498 //------------------------------------------------------------------------------ | 498 //------------------------------------------------------------------------------ |
499 | 499 |
500 Histogram::SampleSet::SampleSet() | 500 Histogram::SampleSet::SampleSet() |
501 : counts_(), | 501 : counts_(), |
502 sum_(0), | 502 sum_(0), |
503 square_sum_(0) { | 503 square_sum_(0) { |
504 } | 504 } |
505 | 505 |
| 506 Histogram::SampleSet::~SampleSet() { |
| 507 } |
| 508 |
506 void Histogram::SampleSet::Resize(const Histogram& histogram) { | 509 void Histogram::SampleSet::Resize(const Histogram& histogram) { |
507 counts_.resize(histogram.bucket_count(), 0); | 510 counts_.resize(histogram.bucket_count(), 0); |
508 } | 511 } |
509 | 512 |
510 void Histogram::SampleSet::CheckSize(const Histogram& histogram) const { | 513 void Histogram::SampleSet::CheckSize(const Histogram& histogram) const { |
511 DCHECK(counts_.size() == histogram.bucket_count()); | 514 DCHECK(counts_.size() == histogram.bucket_count()); |
512 } | 515 } |
513 | 516 |
514 | 517 |
515 void Histogram::SampleSet::Accumulate(Sample value, Count count, | 518 void Histogram::SampleSet::Accumulate(Sample value, Count count, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 return histogram; | 621 return histogram; |
619 } | 622 } |
620 | 623 |
621 scoped_refptr<Histogram> LinearHistogram::FactoryTimeGet( | 624 scoped_refptr<Histogram> LinearHistogram::FactoryTimeGet( |
622 const std::string& name, base::TimeDelta minimum, base::TimeDelta maximum, | 625 const std::string& name, base::TimeDelta minimum, base::TimeDelta maximum, |
623 size_t bucket_count, Flags flags) { | 626 size_t bucket_count, Flags flags) { |
624 return FactoryGet(name, minimum.InMilliseconds(), maximum.InMilliseconds(), | 627 return FactoryGet(name, minimum.InMilliseconds(), maximum.InMilliseconds(), |
625 bucket_count, flags); | 628 bucket_count, flags); |
626 } | 629 } |
627 | 630 |
| 631 LinearHistogram::~LinearHistogram() { |
| 632 } |
| 633 |
628 LinearHistogram::LinearHistogram(const std::string& name, Sample minimum, | 634 LinearHistogram::LinearHistogram(const std::string& name, Sample minimum, |
629 Sample maximum, size_t bucket_count) | 635 Sample maximum, size_t bucket_count) |
630 : Histogram(name, minimum >= 1 ? minimum : 1, maximum, bucket_count) { | 636 : Histogram(name, minimum >= 1 ? minimum : 1, maximum, bucket_count) { |
631 InitializeBucketRange(); | 637 InitializeBucketRange(); |
632 DCHECK(ValidateBucketRanges()); | 638 DCHECK(ValidateBucketRanges()); |
633 } | 639 } |
634 | 640 |
635 LinearHistogram::LinearHistogram(const std::string& name, | 641 LinearHistogram::LinearHistogram(const std::string& name, |
636 TimeDelta minimum, TimeDelta maximum, size_t bucket_count) | 642 TimeDelta minimum, TimeDelta maximum, size_t bucket_count) |
637 : Histogram(name, minimum >= TimeDelta::FromMilliseconds(1) ? | 643 : Histogram(name, minimum >= TimeDelta::FromMilliseconds(1) ? |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 snapshot->push_back(it->second); | 915 snapshot->push_back(it->second); |
910 } | 916 } |
911 } | 917 } |
912 | 918 |
913 // static | 919 // static |
914 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; | 920 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; |
915 // static | 921 // static |
916 Lock* StatisticsRecorder::lock_ = NULL; | 922 Lock* StatisticsRecorder::lock_ = NULL; |
917 // static | 923 // static |
918 bool StatisticsRecorder::dump_on_exit_ = false; | 924 bool StatisticsRecorder::dump_on_exit_ = false; |
OLD | NEW |