| 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 bool HasConstructionArguments(Sample expected_minimum, | 200 bool HasConstructionArguments(Sample expected_minimum, |
| 201 Sample expected_maximum, | 201 Sample expected_maximum, |
| 202 uint32_t expected_bucket_count) const override; | 202 uint32_t expected_bucket_count) const override; |
| 203 void Add(Sample value) override; | 203 void Add(Sample value) override; |
| 204 void AddCount(Sample value, int count) override; | 204 void AddCount(Sample value, int count) override; |
| 205 std::unique_ptr<HistogramSamples> SnapshotSamples() const override; | 205 std::unique_ptr<HistogramSamples> SnapshotSamples() const override; |
| 206 std::unique_ptr<HistogramSamples> SnapshotDelta() override; | 206 std::unique_ptr<HistogramSamples> SnapshotDelta() override; |
| 207 std::unique_ptr<HistogramSamples> SnapshotFinalDelta() const override; | 207 std::unique_ptr<HistogramSamples> SnapshotFinalDelta() const override; |
| 208 void AddSamples(const HistogramSamples& samples) override; | 208 void AddSamples(const HistogramSamples& samples) override; |
| 209 bool AddSamplesFromPickle(base::PickleIterator* iter) override; | 209 bool AddSamplesFromPickle(base::PickleIterator* iter) override; |
| 210 void WriteHTMLGraph(std::string* output) const override; | 210 void WriteHTMLGraph(const HistogramSamples* snapshot, |
| 211 void WriteAscii(std::string* output) const override; | 211 std::string* output) const override; |
| 212 void WriteAscii(const HistogramSamples* snapshot, |
| 213 std::string* output) const override; |
| 212 | 214 |
| 213 protected: | 215 protected: |
| 214 // This class, defined entirely within the .cc file, contains all the | 216 // This class, defined entirely within the .cc file, contains all the |
| 215 // common logic for building a Histogram and can be overridden by more | 217 // common logic for building a Histogram and can be overridden by more |
| 216 // specific types to alter details of how the creation is done. It is | 218 // specific types to alter details of how the creation is done. It is |
| 217 // defined as an embedded class (rather than an anonymous one) so it | 219 // defined as an embedded class (rather than an anonymous one) so it |
| 218 // can access the protected constructors. | 220 // can access the protected constructors. |
| 219 class Factory; | 221 class Factory; |
| 220 | 222 |
| 221 // |ranges| should contain the underflow and overflow buckets. See top | 223 // |ranges| should contain the underflow and overflow buckets. See top |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); | 271 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); |
| 270 | 272 |
| 271 // Implementation of SnapshotSamples function. | 273 // Implementation of SnapshotSamples function. |
| 272 std::unique_ptr<SampleVector> SnapshotSampleVector() const; | 274 std::unique_ptr<SampleVector> SnapshotSampleVector() const; |
| 273 | 275 |
| 274 //---------------------------------------------------------------------------- | 276 //---------------------------------------------------------------------------- |
| 275 // Helpers for emitting Ascii graphic. Each method appends data to output. | 277 // Helpers for emitting Ascii graphic. Each method appends data to output. |
| 276 | 278 |
| 277 void WriteAsciiImpl(bool graph_it, | 279 void WriteAsciiImpl(bool graph_it, |
| 278 const std::string& newline, | 280 const std::string& newline, |
| 281 const SampleVector* snapshot, |
| 279 std::string* output) const; | 282 std::string* output) const; |
| 280 | 283 |
| 281 // Find out how large (graphically) the largest bucket will appear to be. | 284 // Find out how large (graphically) the largest bucket will appear to be. |
| 282 double GetPeakBucketSize(const SampleVector& samples) const; | 285 double GetPeakBucketSize(const SampleVector& samples) const; |
| 283 | 286 |
| 284 // Write a common header message describing this histogram. | 287 // Write a common header message describing this histogram. |
| 285 void WriteAsciiHeader(const SampleVector& samples, | 288 void WriteAsciiHeader(const SampleVector& samples, |
| 286 Count sample_count, | 289 Count sample_count, |
| 287 std::string* output) const; | 290 std::string* output) const; |
| 288 | 291 |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); | 546 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); |
| 544 | 547 |
| 545 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); | 548 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); |
| 546 | 549 |
| 547 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); | 550 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); |
| 548 }; | 551 }; |
| 549 | 552 |
| 550 } // namespace base | 553 } // namespace base |
| 551 | 554 |
| 552 #endif // BASE_METRICS_HISTOGRAM_H_ | 555 #endif // BASE_METRICS_HISTOGRAM_H_ |
| OLD | NEW |