| 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) { } |
| 249 | 251 |
| 250 // Start the timer. | 252 // Start the timer. |
| 251 void Start(); | 253 void Start(); |
| 252 | 254 |
| 253 // Stop the timer and record the results. | 255 // Stop the timer and record the results. |
| 254 void Stop(); | 256 void Stop(); |
| 255 | 257 |
| 256 // Returns true if the timer is running. | 258 // Returns true if the timer is running. |
| 257 bool Running() { | 259 bool Running() { |
| 258 return Enabled() && timer_.IsStarted(); | 260 return Enabled() && (start_time_ != 0) && (stop_time_ == 0); |
| 259 } | 261 } |
| 260 | 262 |
| 261 private: | 263 private: |
| 262 ElapsedTimer timer_; | 264 int64_t start_time_; |
| 265 int64_t stop_time_; |
| 263 }; | 266 }; |
| 264 | 267 |
| 265 // Helper class for scoping a HistogramTimer. | 268 // Helper class for scoping a HistogramTimer. |
| 266 class HistogramTimerScope BASE_EMBEDDED { | 269 class HistogramTimerScope BASE_EMBEDDED { |
| 267 public: | 270 public: |
| 268 explicit HistogramTimerScope(HistogramTimer* timer) : | 271 explicit HistogramTimerScope(HistogramTimer* timer) : |
| 269 timer_(timer) { | 272 timer_(timer) { |
| 270 timer_->Start(); | 273 timer_->Start(); |
| 271 } | 274 } |
| 272 ~HistogramTimerScope() { | 275 ~HistogramTimerScope() { |
| 273 timer_->Stop(); | 276 timer_->Stop(); |
| 274 } | 277 } |
| 275 private: | 278 private: |
| 276 HistogramTimer* timer_; | 279 HistogramTimer* timer_; |
| 277 }; | 280 }; |
| 278 | 281 |
| 279 | 282 |
| 280 } } // namespace v8::internal | 283 } } // namespace v8::internal |
| 281 | 284 |
| 282 #endif // V8_COUNTERS_H_ | 285 #endif // V8_COUNTERS_H_ |
| OLD | NEW |