| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project 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 V8_COUNTERS_H_ | 5 #ifndef V8_COUNTERS_H_ |
| 6 #define V8_COUNTERS_H_ | 6 #define V8_COUNTERS_H_ |
| 7 | 7 |
| 8 #include "include/v8.h" | 8 #include "include/v8.h" |
| 9 #include "src/allocation.h" | 9 #include "src/allocation.h" |
| 10 #include "src/base/platform/elapsed-timer.h" | 10 #include "src/base/platform/elapsed-timer.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 void Start() { time_ = base::TimeDelta(); } | 321 void Start() { time_ = base::TimeDelta(); } |
| 322 void Stop() { AddSample(static_cast<int>(time_.InMicroseconds())); } | 322 void Stop() { AddSample(static_cast<int>(time_.InMicroseconds())); } |
| 323 | 323 |
| 324 // Add a time value ("inner" scope). | 324 // Add a time value ("inner" scope). |
| 325 void Add(base::TimeDelta other) { time_ += other; } | 325 void Add(base::TimeDelta other) { time_ += other; } |
| 326 | 326 |
| 327 private: | 327 private: |
| 328 base::TimeDelta time_; | 328 base::TimeDelta time_; |
| 329 }; | 329 }; |
| 330 | 330 |
| 331 | 331 // A helper class for use with AggregatableHistogramTimer. This is the |
| 332 // A helper class for use with AggregatableHistogramTimer. | 332 // outer-most timer scope used with an AggregatableHistogramTimer. It will |
| 333 // aggregate the information from the inner AggregatedHistogramTimerScope. |
| 333 class AggregatingHistogramTimerScope { | 334 class AggregatingHistogramTimerScope { |
| 334 public: | 335 public: |
| 335 explicit AggregatingHistogramTimerScope(AggregatableHistogramTimer* histogram) | 336 explicit AggregatingHistogramTimerScope(AggregatableHistogramTimer* histogram) |
| 336 : histogram_(histogram) { | 337 : histogram_(histogram) { |
| 337 histogram_->Start(); | 338 histogram_->Start(); |
| 338 } | 339 } |
| 339 ~AggregatingHistogramTimerScope() { histogram_->Stop(); } | 340 ~AggregatingHistogramTimerScope() { histogram_->Stop(); } |
| 340 | 341 |
| 341 private: | 342 private: |
| 342 AggregatableHistogramTimer* histogram_; | 343 AggregatableHistogramTimer* histogram_; |
| 343 }; | 344 }; |
| 344 | 345 |
| 345 | 346 // A helper class for use with AggregatableHistogramTimer, the "inner" scope |
| 346 // A helper class for use with AggregatableHistogramTimer. | 347 // which defines the events to be timed. |
| 347 class AggregatedHistogramTimerScope { | 348 class AggregatedHistogramTimerScope { |
| 348 public: | 349 public: |
| 349 explicit AggregatedHistogramTimerScope(AggregatableHistogramTimer* histogram) | 350 explicit AggregatedHistogramTimerScope(AggregatableHistogramTimer* histogram) |
| 350 : histogram_(histogram) { | 351 : histogram_(histogram) { |
| 351 timer_.Start(); | 352 timer_.Start(); |
| 352 } | 353 } |
| 353 ~AggregatedHistogramTimerScope() { histogram_->Add(timer_.Elapsed()); } | 354 ~AggregatedHistogramTimerScope() { histogram_->Add(timer_.Elapsed()); } |
| 354 | 355 |
| 355 private: | 356 private: |
| 356 base::ElapsedTimer timer_; | 357 base::ElapsedTimer timer_; |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 | 897 |
| 897 explicit Counters(Isolate* isolate); | 898 explicit Counters(Isolate* isolate); |
| 898 | 899 |
| 899 DISALLOW_IMPLICIT_CONSTRUCTORS(Counters); | 900 DISALLOW_IMPLICIT_CONSTRUCTORS(Counters); |
| 900 }; | 901 }; |
| 901 | 902 |
| 902 } // namespace internal | 903 } // namespace internal |
| 903 } // namespace v8 | 904 } // namespace v8 |
| 904 | 905 |
| 905 #endif // V8_COUNTERS_H_ | 906 #endif // V8_COUNTERS_H_ |
| OLD | NEW |