| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 FRIEND_TEST_ALL_PREFIXES(HistogramTest, BoundsTest); | 217 FRIEND_TEST_ALL_PREFIXES(HistogramTest, BoundsTest); |
| 218 FRIEND_TEST_ALL_PREFIXES(HistogramTest, BucketPlacementTest); | 218 FRIEND_TEST_ALL_PREFIXES(HistogramTest, BucketPlacementTest); |
| 219 FRIEND_TEST_ALL_PREFIXES(HistogramTest, CorruptBucketBounds); | 219 FRIEND_TEST_ALL_PREFIXES(HistogramTest, CorruptBucketBounds); |
| 220 FRIEND_TEST_ALL_PREFIXES(HistogramTest, CorruptSampleCounts); | 220 FRIEND_TEST_ALL_PREFIXES(HistogramTest, CorruptSampleCounts); |
| 221 FRIEND_TEST_ALL_PREFIXES(HistogramTest, NameMatchTest); | 221 FRIEND_TEST_ALL_PREFIXES(HistogramTest, NameMatchTest); |
| 222 FRIEND_TEST_ALL_PREFIXES(HistogramTest, AddCountTest); | 222 FRIEND_TEST_ALL_PREFIXES(HistogramTest, AddCountTest); |
| 223 | 223 |
| 224 friend class StatisticsRecorder; // To allow it to delete duplicates. | 224 friend class StatisticsRecorder; // To allow it to delete duplicates. |
| 225 friend class StatisticsRecorderTest; | 225 friend class StatisticsRecorderTest; |
| 226 | 226 |
| 227 friend BASE_EXPORT_PRIVATE HistogramBase* DeserializeHistogramInfo( | 227 friend BASE_EXPORT HistogramBase* DeserializeHistogramInfo( |
| 228 base::PickleIterator* iter); | 228 base::PickleIterator* iter); |
| 229 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); | 229 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); |
| 230 | 230 |
| 231 // Implementation of SnapshotSamples function. | 231 // Implementation of SnapshotSamples function. |
| 232 scoped_ptr<SampleVector> SnapshotSampleVector() const; | 232 scoped_ptr<SampleVector> SnapshotSampleVector() const; |
| 233 | 233 |
| 234 //---------------------------------------------------------------------------- | 234 //---------------------------------------------------------------------------- |
| 235 // Helpers for emitting Ascii graphic. Each method appends data to output. | 235 // Helpers for emitting Ascii graphic. Each method appends data to output. |
| 236 | 236 |
| 237 void WriteAsciiImpl(bool graph_it, | 237 void WriteAsciiImpl(bool graph_it, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 | 342 |
| 343 // If we have a description for a bucket, then return that. Otherwise | 343 // If we have a description for a bucket, then return that. Otherwise |
| 344 // let parent class provide a (numeric) description. | 344 // let parent class provide a (numeric) description. |
| 345 const std::string GetAsciiBucketRange(size_t i) const override; | 345 const std::string GetAsciiBucketRange(size_t i) const override; |
| 346 | 346 |
| 347 // Skip printing of name for numeric range if we have a name (and if this is | 347 // Skip printing of name for numeric range if we have a name (and if this is |
| 348 // an empty bucket). | 348 // an empty bucket). |
| 349 bool PrintEmptyBucket(size_t index) const override; | 349 bool PrintEmptyBucket(size_t index) const override; |
| 350 | 350 |
| 351 private: | 351 private: |
| 352 friend BASE_EXPORT_PRIVATE HistogramBase* DeserializeHistogramInfo( | 352 friend BASE_EXPORT HistogramBase* DeserializeHistogramInfo( |
| 353 base::PickleIterator* iter); | 353 base::PickleIterator* iter); |
| 354 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); | 354 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); |
| 355 | 355 |
| 356 // For some ranges, we store a printable description of a bucket range. | 356 // For some ranges, we store a printable description of a bucket range. |
| 357 // If there is no description, then GetAsciiBucketRange() uses parent class | 357 // If there is no description, then GetAsciiBucketRange() uses parent class |
| 358 // to provide a description. | 358 // to provide a description. |
| 359 typedef std::map<Sample, std::string> BucketDescriptionMap; | 359 typedef std::map<Sample, std::string> BucketDescriptionMap; |
| 360 BucketDescriptionMap bucket_description_; | 360 BucketDescriptionMap bucket_description_; |
| 361 | 361 |
| 362 DISALLOW_COPY_AND_ASSIGN(LinearHistogram); | 362 DISALLOW_COPY_AND_ASSIGN(LinearHistogram); |
| 363 }; | 363 }; |
| 364 | 364 |
| 365 //------------------------------------------------------------------------------ | 365 //------------------------------------------------------------------------------ |
| 366 | 366 |
| 367 // BooleanHistogram is a histogram for booleans. | 367 // BooleanHistogram is a histogram for booleans. |
| 368 class BASE_EXPORT BooleanHistogram : public LinearHistogram { | 368 class BASE_EXPORT BooleanHistogram : public LinearHistogram { |
| 369 public: | 369 public: |
| 370 static HistogramBase* FactoryGet(const std::string& name, int32 flags); | 370 static HistogramBase* FactoryGet(const std::string& name, int32 flags); |
| 371 | 371 |
| 372 // Overload of the above function that takes a const char* |name| param, | 372 // Overload of the above function that takes a const char* |name| param, |
| 373 // to avoid code bloat from the std::string constructor being inlined into | 373 // to avoid code bloat from the std::string constructor being inlined into |
| 374 // call sites. | 374 // call sites. |
| 375 static HistogramBase* FactoryGet(const char* name, int32 flags); | 375 static HistogramBase* FactoryGet(const char* name, int32 flags); |
| 376 | 376 |
| 377 HistogramType GetHistogramType() const override; | 377 HistogramType GetHistogramType() const override; |
| 378 | 378 |
| 379 private: | 379 private: |
| 380 BooleanHistogram(const std::string& name, const BucketRanges* ranges); | 380 BooleanHistogram(const std::string& name, const BucketRanges* ranges); |
| 381 | 381 |
| 382 friend BASE_EXPORT_PRIVATE HistogramBase* DeserializeHistogramInfo( | 382 friend BASE_EXPORT HistogramBase* DeserializeHistogramInfo( |
| 383 base::PickleIterator* iter); | 383 base::PickleIterator* iter); |
| 384 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); | 384 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); |
| 385 | 385 |
| 386 DISALLOW_COPY_AND_ASSIGN(BooleanHistogram); | 386 DISALLOW_COPY_AND_ASSIGN(BooleanHistogram); |
| 387 }; | 387 }; |
| 388 | 388 |
| 389 //------------------------------------------------------------------------------ | 389 //------------------------------------------------------------------------------ |
| 390 | 390 |
| 391 // CustomHistogram is a histogram for a set of custom integers. | 391 // CustomHistogram is a histogram for a set of custom integers. |
| 392 class BASE_EXPORT CustomHistogram : public Histogram { | 392 class BASE_EXPORT CustomHistogram : public Histogram { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 420 protected: | 420 protected: |
| 421 CustomHistogram(const std::string& name, | 421 CustomHistogram(const std::string& name, |
| 422 const BucketRanges* ranges); | 422 const BucketRanges* ranges); |
| 423 | 423 |
| 424 // HistogramBase implementation: | 424 // HistogramBase implementation: |
| 425 bool SerializeInfoImpl(base::Pickle* pickle) const override; | 425 bool SerializeInfoImpl(base::Pickle* pickle) const override; |
| 426 | 426 |
| 427 double GetBucketSize(Count current, size_t i) const override; | 427 double GetBucketSize(Count current, size_t i) const override; |
| 428 | 428 |
| 429 private: | 429 private: |
| 430 friend BASE_EXPORT_PRIVATE HistogramBase* DeserializeHistogramInfo( | 430 friend BASE_EXPORT HistogramBase* DeserializeHistogramInfo( |
| 431 base::PickleIterator* iter); | 431 base::PickleIterator* iter); |
| 432 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); | 432 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); |
| 433 | 433 |
| 434 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); | 434 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); |
| 435 static BucketRanges* CreateBucketRangesFromCustomRanges( | 435 static BucketRanges* CreateBucketRangesFromCustomRanges( |
| 436 const std::vector<Sample>& custom_ranges); | 436 const std::vector<Sample>& custom_ranges); |
| 437 | 437 |
| 438 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); | 438 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); |
| 439 }; | 439 }; |
| 440 | 440 |
| 441 } // namespace base | 441 } // namespace base |
| 442 | 442 |
| 443 #endif // BASE_METRICS_HISTOGRAM_H_ | 443 #endif // BASE_METRICS_HISTOGRAM_H_ |
| OLD | NEW |