OLD | NEW |
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_export.h" | 11 #include "base/base_export.h" |
| 12 #include "base/compiler_specific.h" |
12 #include "base/metrics/stats_table.h" | 13 #include "base/metrics/stats_table.h" |
13 #include "base/time.h" | 14 #include "base/time.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 | 17 |
17 // StatsCounters are dynamically created values which can be tracked in | 18 // StatsCounters are dynamically created values which can be tracked in |
18 // the StatsTable. They are designed to be lightweight to create and | 19 // the StatsTable. They are designed to be lightweight to create and |
19 // easy to use. | 20 // easy to use. |
20 // | 21 // |
21 // Since StatsCounters can be created dynamically by name, there is | 22 // Since StatsCounters can be created dynamically by name, there is |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 158 |
158 // A StatsRate is a timer that keeps a count of the number of intervals added so | 159 // A StatsRate is a timer that keeps a count of the number of intervals added so |
159 // that several statistics can be produced: | 160 // that several statistics can be produced: |
160 // min, max, avg, count, total | 161 // min, max, avg, count, total |
161 class BASE_EXPORT StatsRate : public StatsCounterTimer { | 162 class BASE_EXPORT StatsRate : public StatsCounterTimer { |
162 public: | 163 public: |
163 // Constructs and starts the timer. | 164 // Constructs and starts the timer. |
164 explicit StatsRate(const std::string& name); | 165 explicit StatsRate(const std::string& name); |
165 virtual ~StatsRate(); | 166 virtual ~StatsRate(); |
166 | 167 |
167 virtual void Add(int value); | 168 virtual void Add(int value) OVERRIDE; |
168 | 169 |
169 private: | 170 private: |
170 StatsCounter counter_; | 171 StatsCounter counter_; |
171 StatsCounter largest_add_; | 172 StatsCounter largest_add_; |
172 }; | 173 }; |
173 | 174 |
174 | 175 |
175 // Helper class for scoping a timer or rate. | 176 // Helper class for scoping a timer or rate. |
176 template<class T> class StatsScope { | 177 template<class T> class StatsScope { |
177 public: | 178 public: |
(...skipping 10 matching lines...) Expand all Loading... |
188 timer_.Stop(); | 189 timer_.Stop(); |
189 } | 190 } |
190 | 191 |
191 private: | 192 private: |
192 T& timer_; | 193 T& timer_; |
193 }; | 194 }; |
194 | 195 |
195 } // namespace base | 196 } // namespace base |
196 | 197 |
197 #endif // BASE_METRICS_STATS_COUNTERS_H_ | 198 #endif // BASE_METRICS_STATS_COUNTERS_H_ |
OLD | NEW |