OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 238 |
239 // A HistogramTimer allows distributions of results to be created. | 239 // A HistogramTimer allows distributions of results to be created. |
240 class HistogramTimer : public Histogram { | 240 class HistogramTimer : public Histogram { |
241 public: | 241 public: |
242 HistogramTimer() { } | 242 HistogramTimer() { } |
243 HistogramTimer(const char* name, | 243 HistogramTimer(const char* name, |
244 int min, | 244 int min, |
245 int max, | 245 int max, |
246 int num_buckets, | 246 int num_buckets, |
247 Isolate* isolate) | 247 Isolate* isolate) |
248 : Histogram(name, min, max, num_buckets, isolate), | 248 : Histogram(name, min, max, num_buckets, isolate) {} |
249 start_time_(0), | |
250 stop_time_(0) { } | |
251 | 249 |
252 // Start the timer. | 250 // Start the timer. |
253 void Start(); | 251 void Start(); |
254 | 252 |
255 // Stop the timer and record the results. | 253 // Stop the timer and record the results. |
256 void Stop(); | 254 void Stop(); |
257 | 255 |
258 // Returns true if the timer is running. | 256 // Returns true if the timer is running. |
259 bool Running() { | 257 bool Running() { |
260 return Enabled() && (start_time_ != 0) && (stop_time_ == 0); | 258 return Enabled() && timer_.IsStarted(); |
261 } | 259 } |
262 | 260 |
263 private: | 261 private: |
264 int64_t start_time_; | 262 ElapsedTimer timer_; |
265 int64_t stop_time_; | |
266 }; | 263 }; |
267 | 264 |
268 // Helper class for scoping a HistogramTimer. | 265 // Helper class for scoping a HistogramTimer. |
269 class HistogramTimerScope BASE_EMBEDDED { | 266 class HistogramTimerScope BASE_EMBEDDED { |
270 public: | 267 public: |
271 explicit HistogramTimerScope(HistogramTimer* timer) : | 268 explicit HistogramTimerScope(HistogramTimer* timer) : |
272 timer_(timer) { | 269 timer_(timer) { |
273 timer_->Start(); | 270 timer_->Start(); |
274 } | 271 } |
275 ~HistogramTimerScope() { | 272 ~HistogramTimerScope() { |
276 timer_->Stop(); | 273 timer_->Stop(); |
277 } | 274 } |
278 private: | 275 private: |
279 HistogramTimer* timer_; | 276 HistogramTimer* timer_; |
280 }; | 277 }; |
281 | 278 |
282 | 279 |
283 } } // namespace v8::internal | 280 } } // namespace v8::internal |
284 | 281 |
285 #endif // V8_COUNTERS_H_ | 282 #endif // V8_COUNTERS_H_ |
OLD | NEW |