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

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

Issue 6736019: Base: A few more files using BASE_API (for base.dll) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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/message_pump_win.h ('k') | base/metrics/stats_counters.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 18 matching lines...) Expand all
29 // gigantic range with the addition of very few buckets. 29 // gigantic range with the addition of very few buckets.
30 30
31 #ifndef BASE_METRICS_HISTOGRAM_H_ 31 #ifndef BASE_METRICS_HISTOGRAM_H_
32 #define BASE_METRICS_HISTOGRAM_H_ 32 #define BASE_METRICS_HISTOGRAM_H_
33 #pragma once 33 #pragma once
34 34
35 #include <map> 35 #include <map>
36 #include <string> 36 #include <string>
37 #include <vector> 37 #include <vector>
38 38
39 #include "base/base_api.h"
39 #include "base/gtest_prod_util.h" 40 #include "base/gtest_prod_util.h"
40 #include "base/ref_counted.h" 41 #include "base/ref_counted.h"
41 #include "base/logging.h" 42 #include "base/logging.h"
42 #include "base/time.h" 43 #include "base/time.h"
43 44
44 class Pickle; 45 class Pickle;
45 46
46 namespace base { 47 namespace base {
47 48
48 class Lock; 49 class Lock;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 if (counter.get()) counter->Add(sample); \ 230 if (counter.get()) counter->Add(sample); \
230 } while (0) 231 } while (0)
231 232
232 //------------------------------------------------------------------------------ 233 //------------------------------------------------------------------------------
233 234
234 class BooleanHistogram; 235 class BooleanHistogram;
235 class CustomHistogram; 236 class CustomHistogram;
236 class Histogram; 237 class Histogram;
237 class LinearHistogram; 238 class LinearHistogram;
238 239
239 class Histogram : public base::RefCountedThreadSafe<Histogram> { 240 class BASE_API Histogram : public base::RefCountedThreadSafe<Histogram> {
240 public: 241 public:
241 typedef int Sample; // Used for samples (and ranges of samples). 242 typedef int Sample; // Used for samples (and ranges of samples).
242 typedef int Count; // Used to count samples in a bucket. 243 typedef int Count; // Used to count samples in a bucket.
243 static const Sample kSampleType_MAX = INT_MAX; 244 static const Sample kSampleType_MAX = INT_MAX;
244 // Initialize maximum number of buckets in histograms as 16,384. 245 // Initialize maximum number of buckets in histograms as 16,384.
245 static const size_t kBucketCount_MAX; 246 static const size_t kBucketCount_MAX;
246 247
247 typedef std::vector<Count> Counts; 248 typedef std::vector<Count> Counts;
248 typedef std::vector<Sample> Ranges; 249 typedef std::vector<Sample> Ranges;
249 250
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 }; 289 };
289 290
290 struct DescriptionPair { 291 struct DescriptionPair {
291 Sample sample; 292 Sample sample;
292 const char* description; // Null means end of a list of pairs. 293 const char* description; // Null means end of a list of pairs.
293 }; 294 };
294 295
295 //---------------------------------------------------------------------------- 296 //----------------------------------------------------------------------------
296 // Statistic values, developed over the life of the histogram. 297 // Statistic values, developed over the life of the histogram.
297 298
298 class SampleSet { 299 class BASE_API SampleSet {
299 public: 300 public:
300 explicit SampleSet(); 301 explicit SampleSet();
301 ~SampleSet(); 302 ~SampleSet();
302 303
303 // Adjust size of counts_ for use with given histogram. 304 // Adjust size of counts_ for use with given histogram.
304 void Resize(const Histogram& histogram); 305 void Resize(const Histogram& histogram);
305 void CheckSize(const Histogram& histogram) const; 306 void CheckSize(const Histogram& histogram) const;
306 307
307 // Accessor for histogram to make routine additions. 308 // Accessor for histogram to make routine additions.
308 void Accumulate(Sample value, Count count, size_t index); 309 void Accumulate(Sample value, Count count, size_t index);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 // sample. 542 // sample.
542 SampleSet sample_; 543 SampleSet sample_;
543 544
544 DISALLOW_COPY_AND_ASSIGN(Histogram); 545 DISALLOW_COPY_AND_ASSIGN(Histogram);
545 }; 546 };
546 547
547 //------------------------------------------------------------------------------ 548 //------------------------------------------------------------------------------
548 549
549 // LinearHistogram is a more traditional histogram, with evenly spaced 550 // LinearHistogram is a more traditional histogram, with evenly spaced
550 // buckets. 551 // buckets.
551 class LinearHistogram : public Histogram { 552 class BASE_API LinearHistogram : public Histogram {
552 public: 553 public:
553 virtual ~LinearHistogram(); 554 virtual ~LinearHistogram();
554 555
555 /* minimum should start from 1. 0 is as minimum is invalid. 0 is an implicit 556 /* minimum should start from 1. 0 is as minimum is invalid. 0 is an implicit
556 default underflow bucket. */ 557 default underflow bucket. */
557 static scoped_refptr<Histogram> FactoryGet(const std::string& name, 558 static scoped_refptr<Histogram> FactoryGet(const std::string& name,
558 Sample minimum, Sample maximum, size_t bucket_count, Flags flags); 559 Sample minimum, Sample maximum, size_t bucket_count, Flags flags);
559 static scoped_refptr<Histogram> FactoryTimeGet(const std::string& name, 560 static scoped_refptr<Histogram> FactoryTimeGet(const std::string& name,
560 TimeDelta minimum, TimeDelta maximum, size_t bucket_count, 561 TimeDelta minimum, TimeDelta maximum, size_t bucket_count,
561 Flags flags); 562 Flags flags);
(...skipping 30 matching lines...) Expand all
592 // to provide a description. 593 // to provide a description.
593 typedef std::map<Sample, std::string> BucketDescriptionMap; 594 typedef std::map<Sample, std::string> BucketDescriptionMap;
594 BucketDescriptionMap bucket_description_; 595 BucketDescriptionMap bucket_description_;
595 596
596 DISALLOW_COPY_AND_ASSIGN(LinearHistogram); 597 DISALLOW_COPY_AND_ASSIGN(LinearHistogram);
597 }; 598 };
598 599
599 //------------------------------------------------------------------------------ 600 //------------------------------------------------------------------------------
600 601
601 // BooleanHistogram is a histogram for booleans. 602 // BooleanHistogram is a histogram for booleans.
602 class BooleanHistogram : public LinearHistogram { 603 class BASE_API BooleanHistogram : public LinearHistogram {
603 public: 604 public:
604 static scoped_refptr<Histogram> FactoryGet(const std::string& name, 605 static scoped_refptr<Histogram> FactoryGet(const std::string& name,
605 Flags flags); 606 Flags flags);
606 607
607 virtual ClassType histogram_type() const; 608 virtual ClassType histogram_type() const;
608 609
609 virtual void AddBoolean(bool value); 610 virtual void AddBoolean(bool value);
610 611
611 private: 612 private:
612 explicit BooleanHistogram(const std::string& name); 613 explicit BooleanHistogram(const std::string& name);
613 614
614 DISALLOW_COPY_AND_ASSIGN(BooleanHistogram); 615 DISALLOW_COPY_AND_ASSIGN(BooleanHistogram);
615 }; 616 };
616 617
617 //------------------------------------------------------------------------------ 618 //------------------------------------------------------------------------------
618 619
619 // CustomHistogram is a histogram for a set of custom integers. 620 // CustomHistogram is a histogram for a set of custom integers.
620 class CustomHistogram : public Histogram { 621 class BASE_API CustomHistogram : public Histogram {
621 public: 622 public:
622 623
623 static scoped_refptr<Histogram> FactoryGet(const std::string& name, 624 static scoped_refptr<Histogram> FactoryGet(const std::string& name,
624 const std::vector<Sample>& custom_ranges, Flags flags); 625 const std::vector<Sample>& custom_ranges, Flags flags);
625 626
626 // Overridden from Histogram: 627 // Overridden from Histogram:
627 virtual ClassType histogram_type() const; 628 virtual ClassType histogram_type() const;
628 629
629 protected: 630 protected:
630 CustomHistogram(const std::string& name, 631 CustomHistogram(const std::string& name,
631 const std::vector<Sample>& custom_ranges); 632 const std::vector<Sample>& custom_ranges);
632 633
633 // Initialize ranges_ mapping. 634 // Initialize ranges_ mapping.
634 void InitializedCustomBucketRange(const std::vector<Sample>& custom_ranges); 635 void InitializedCustomBucketRange(const std::vector<Sample>& custom_ranges);
635 virtual double GetBucketSize(Count current, size_t i) const; 636 virtual double GetBucketSize(Count current, size_t i) const;
636 637
637 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); 638 DISALLOW_COPY_AND_ASSIGN(CustomHistogram);
638 }; 639 };
639 640
640 //------------------------------------------------------------------------------ 641 //------------------------------------------------------------------------------
641 // StatisticsRecorder handles all histograms in the system. It provides a 642 // StatisticsRecorder handles all histograms in the system. It provides a
642 // general place for histograms to register, and supports a global API for 643 // general place for histograms to register, and supports a global API for
643 // accessing (i.e., dumping, or graphing) the data in all the histograms. 644 // accessing (i.e., dumping, or graphing) the data in all the histograms.
644 645
645 class StatisticsRecorder { 646 class BASE_API StatisticsRecorder {
646 public: 647 public:
647 typedef std::vector<scoped_refptr<Histogram> > Histograms; 648 typedef std::vector<scoped_refptr<Histogram> > Histograms;
648 649
649 StatisticsRecorder(); 650 StatisticsRecorder();
650 651
651 ~StatisticsRecorder(); 652 ~StatisticsRecorder();
652 653
653 // Find out if histograms can now be registered into our list. 654 // Find out if histograms can now be registered into our list.
654 static bool IsActive(); 655 static bool IsActive();
655 656
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 697
697 // Dump all known histograms to log. 698 // Dump all known histograms to log.
698 static bool dump_on_exit_; 699 static bool dump_on_exit_;
699 700
700 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); 701 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder);
701 }; 702 };
702 703
703 } // namespace base 704 } // namespace base
704 705
705 #endif // BASE_METRICS_HISTOGRAM_H_ 706 #endif // BASE_METRICS_HISTOGRAM_H_
OLDNEW
« no previous file with comments | « base/message_pump_win.h ('k') | base/metrics/stats_counters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698