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

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

Issue 7461141: Rename BASE_API to BASE_EXPORT. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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/histogram.h ('k') | base/metrics/stats_table.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 #ifndef BASE_METRICS_STATS_COUNTERS_H_ 5 #ifndef BASE_METRICS_STATS_COUNTERS_H_
6 #define BASE_METRICS_STATS_COUNTERS_H_ 6 #define BASE_METRICS_STATS_COUNTERS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/base_api.h" 11 #include "base/base_export.h"
12 #include "base/metrics/stats_table.h" 12 #include "base/metrics/stats_table.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 14
15 namespace base { 15 namespace base {
16 16
17 // StatsCounters are dynamically created values which can be tracked in 17 // StatsCounters are dynamically created values which can be tracked in
18 // the StatsTable. They are designed to be lightweight to create and 18 // the StatsTable. They are designed to be lightweight to create and
19 // easy to use. 19 // easy to use.
20 // 20 //
21 // Since StatsCounters can be created dynamically by name, there is 21 // Since StatsCounters can be created dynamically by name, there is
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 #else // NDEBUG 68 #else // NDEBUG
69 69
70 #define DSTATS_COUNTER(name, delta) do {} while (0) 70 #define DSTATS_COUNTER(name, delta) do {} while (0)
71 #define DSIMPLE_STATS_COUNTER(name) do {} while (0) 71 #define DSIMPLE_STATS_COUNTER(name) do {} while (0)
72 #define DRATE_COUNTER(name, duration) do {} while (0) 72 #define DRATE_COUNTER(name, duration) do {} while (0)
73 73
74 #endif // NDEBUG 74 #endif // NDEBUG
75 75
76 //------------------------------------------------------------------------------ 76 //------------------------------------------------------------------------------
77 // StatsCounter represents a counter in the StatsTable class. 77 // StatsCounter represents a counter in the StatsTable class.
78 class BASE_API StatsCounter { 78 class BASE_EXPORT StatsCounter {
79 public: 79 public:
80 // Create a StatsCounter object. 80 // Create a StatsCounter object.
81 explicit StatsCounter(const std::string& name); 81 explicit StatsCounter(const std::string& name);
82 virtual ~StatsCounter(); 82 virtual ~StatsCounter();
83 83
84 // Sets the counter to a specific value. 84 // Sets the counter to a specific value.
85 void Set(int value); 85 void Set(int value);
86 86
87 // Increments the counter. 87 // Increments the counter.
88 void Increment() { 88 void Increment() {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // The counter id in the table. We initialize to -1 (an invalid value) 122 // The counter id in the table. We initialize to -1 (an invalid value)
123 // and then cache it once it has been looked up. The counter_id is 123 // and then cache it once it has been looked up. The counter_id is
124 // valid across all threads and processes. 124 // valid across all threads and processes.
125 int32 counter_id_; 125 int32 counter_id_;
126 }; 126 };
127 127
128 128
129 // A StatsCounterTimer is a StatsCounter which keeps a timer during 129 // A StatsCounterTimer is a StatsCounter which keeps a timer during
130 // the scope of the StatsCounterTimer. On destruction, it will record 130 // the scope of the StatsCounterTimer. On destruction, it will record
131 // its time measurement. 131 // its time measurement.
132 class BASE_API StatsCounterTimer : protected StatsCounter { 132 class BASE_EXPORT StatsCounterTimer : protected StatsCounter {
133 public: 133 public:
134 // Constructs and starts the timer. 134 // Constructs and starts the timer.
135 explicit StatsCounterTimer(const std::string& name); 135 explicit StatsCounterTimer(const std::string& name);
136 virtual ~StatsCounterTimer(); 136 virtual ~StatsCounterTimer();
137 137
138 // Start the timer. 138 // Start the timer.
139 void Start(); 139 void Start();
140 140
141 // Stop the timer and record the results. 141 // Stop the timer and record the results.
142 void Stop(); 142 void Stop();
143 143
144 // Returns true if the timer is running. 144 // Returns true if the timer is running.
145 bool Running(); 145 bool Running();
146 146
147 // Accept a TimeDelta to increment. 147 // Accept a TimeDelta to increment.
148 virtual void AddTime(TimeDelta time); 148 virtual void AddTime(TimeDelta time);
149 149
150 protected: 150 protected:
151 // Compute the delta between start and stop, in milliseconds. 151 // Compute the delta between start and stop, in milliseconds.
152 void Record(); 152 void Record();
153 153
154 TimeTicks start_time_; 154 TimeTicks start_time_;
155 TimeTicks stop_time_; 155 TimeTicks stop_time_;
156 }; 156 };
157 157
158 // A StatsRate is a timer that keeps a count of the number of intervals added so 158 // A StatsRate is a timer that keeps a count of the number of intervals added so
159 // that several statistics can be produced: 159 // that several statistics can be produced:
160 // min, max, avg, count, total 160 // min, max, avg, count, total
161 class BASE_API StatsRate : public StatsCounterTimer { 161 class BASE_EXPORT StatsRate : public StatsCounterTimer {
162 public: 162 public:
163 // Constructs and starts the timer. 163 // Constructs and starts the timer.
164 explicit StatsRate(const std::string& name); 164 explicit StatsRate(const std::string& name);
165 virtual ~StatsRate(); 165 virtual ~StatsRate();
166 166
167 virtual void Add(int value); 167 virtual void Add(int value);
168 168
169 private: 169 private:
170 StatsCounter counter_; 170 StatsCounter counter_;
171 StatsCounter largest_add_; 171 StatsCounter largest_add_;
(...skipping 16 matching lines...) Expand all
188 timer_.Stop(); 188 timer_.Stop();
189 } 189 }
190 190
191 private: 191 private:
192 T& timer_; 192 T& timer_;
193 }; 193 };
194 194
195 } // namespace base 195 } // namespace base
196 196
197 #endif // BASE_METRICS_STATS_COUNTERS_H_ 197 #endif // BASE_METRICS_STATS_COUNTERS_H_
OLDNEW
« no previous file with comments | « base/metrics/histogram.h ('k') | base/metrics/stats_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698