| 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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 void Start() { time_ = base::TimeDelta(); } | 323 void Start() { time_ = base::TimeDelta(); } |
| 324 void Stop() { AddSample(static_cast<int>(time_.InMicroseconds())); } | 324 void Stop() { AddSample(static_cast<int>(time_.InMicroseconds())); } |
| 325 | 325 |
| 326 // Add a time value ("inner" scope). | 326 // Add a time value ("inner" scope). |
| 327 void Add(base::TimeDelta other) { time_ += other; } | 327 void Add(base::TimeDelta other) { time_ += other; } |
| 328 | 328 |
| 329 private: | 329 private: |
| 330 base::TimeDelta time_; | 330 base::TimeDelta time_; |
| 331 }; | 331 }; |
| 332 | 332 |
| 333 | 333 // A helper class for use with AggregatableHistogramTimer. This is the |
| 334 // A helper class for use with AggregatableHistogramTimer. | 334 // outer-most timer scope used with an AggregatableHistogramTimer. It will |
| 335 // aggregate the information from the inner AggregatedHistogramTimerScope. |
| 335 class AggregatingHistogramTimerScope { | 336 class AggregatingHistogramTimerScope { |
| 336 public: | 337 public: |
| 337 explicit AggregatingHistogramTimerScope(AggregatableHistogramTimer* histogram) | 338 explicit AggregatingHistogramTimerScope(AggregatableHistogramTimer* histogram) |
| 338 : histogram_(histogram) { | 339 : histogram_(histogram) { |
| 339 histogram_->Start(); | 340 histogram_->Start(); |
| 340 } | 341 } |
| 341 ~AggregatingHistogramTimerScope() { histogram_->Stop(); } | 342 ~AggregatingHistogramTimerScope() { histogram_->Stop(); } |
| 342 | 343 |
| 343 private: | 344 private: |
| 344 AggregatableHistogramTimer* histogram_; | 345 AggregatableHistogramTimer* histogram_; |
| 345 }; | 346 }; |
| 346 | 347 |
| 347 | 348 // A helper class for use with AggregatableHistogramTimer, the "inner" scope |
| 348 // A helper class for use with AggregatableHistogramTimer. | 349 // which defines the events to be timed. |
| 349 class AggregatedHistogramTimerScope { | 350 class AggregatedHistogramTimerScope { |
| 350 public: | 351 public: |
| 351 explicit AggregatedHistogramTimerScope(AggregatableHistogramTimer* histogram) | 352 explicit AggregatedHistogramTimerScope(AggregatableHistogramTimer* histogram) |
| 352 : histogram_(histogram) { | 353 : histogram_(histogram) { |
| 353 timer_.Start(); | 354 timer_.Start(); |
| 354 } | 355 } |
| 355 ~AggregatedHistogramTimerScope() { histogram_->Add(timer_.Elapsed()); } | 356 ~AggregatedHistogramTimerScope() { histogram_->Add(timer_.Elapsed()); } |
| 356 | 357 |
| 357 private: | 358 private: |
| 358 base::ElapsedTimer timer_; | 359 base::ElapsedTimer timer_; |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 | 916 |
| 916 explicit Counters(Isolate* isolate); | 917 explicit Counters(Isolate* isolate); |
| 917 | 918 |
| 918 DISALLOW_IMPLICIT_CONSTRUCTORS(Counters); | 919 DISALLOW_IMPLICIT_CONSTRUCTORS(Counters); |
| 919 }; | 920 }; |
| 920 | 921 |
| 921 } // namespace internal | 922 } // namespace internal |
| 922 } // namespace v8 | 923 } // namespace v8 |
| 923 | 924 |
| 924 #endif // V8_COUNTERS_H_ | 925 #endif // V8_COUNTERS_H_ |
| OLD | NEW |