| 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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 double value = (current_value + last_value_) / 2; | 476 double value = (current_value + last_value_) / 2; |
| 477 // The aggregate_value_ is the average for [start_ms_; last_ms_]. | 477 // The aggregate_value_ is the average for [start_ms_; last_ms_]. |
| 478 // The value is the average for [last_ms_; current_ms]. | 478 // The value is the average for [last_ms_; current_ms]. |
| 479 // Return the weighted average of the aggregate_value_ and the value. | 479 // Return the weighted average of the aggregate_value_ and the value. |
| 480 return aggregate_value_ * ((last_ms_ - start_ms_) / interval_ms) + | 480 return aggregate_value_ * ((last_ms_ - start_ms_) / interval_ms) + |
| 481 value * ((current_ms - last_ms_) / interval_ms); | 481 value * ((current_ms - last_ms_) / interval_ms); |
| 482 } | 482 } |
| 483 | 483 |
| 484 struct RuntimeCallCounter { | 484 struct RuntimeCallCounter { |
| 485 explicit RuntimeCallCounter(const char* name) : name(name) {} | 485 explicit RuntimeCallCounter(const char* name) : name(name) {} |
| 486 void Reset(); | 486 V8_NOINLINE void Reset(); |
| 487 V8_NOINLINE void Dump(std::stringstream& out); | 487 V8_NOINLINE void Dump(std::stringstream& out); |
| 488 | 488 |
| 489 const char* name; | 489 const char* name; |
| 490 int64_t count = 0; | 490 int64_t count = 0; |
| 491 base::TimeDelta time; | 491 base::TimeDelta time; |
| 492 }; | 492 }; |
| 493 | 493 |
| 494 // RuntimeCallTimer is used to keep track of the stack of currently active | 494 // RuntimeCallTimer is used to keep track of the stack of currently active |
| 495 // timers used for properly measuring the own time of a RuntimeCallCounter. | 495 // timers used for properly measuring the own time of a RuntimeCallCounter. |
| 496 class RuntimeCallTimer { | 496 class RuntimeCallTimer { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 // the time delta to the current_counter and subtract the delta from its | 791 // the time delta to the current_counter and subtract the delta from its |
| 792 // parent. | 792 // parent. |
| 793 static void Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer); | 793 static void Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer); |
| 794 | 794 |
| 795 // Set counter id for the innermost measurement. It can be used to refine | 795 // Set counter id for the innermost measurement. It can be used to refine |
| 796 // event kind when a runtime entry counter is too generic. | 796 // event kind when a runtime entry counter is too generic. |
| 797 static void CorrectCurrentCounterId(RuntimeCallStats* stats, | 797 static void CorrectCurrentCounterId(RuntimeCallStats* stats, |
| 798 CounterId counter_id); | 798 CounterId counter_id); |
| 799 | 799 |
| 800 void Reset(); | 800 void Reset(); |
| 801 V8_NOINLINE void Print(std::ostream& os); | 801 void Print(std::ostream& os); |
| 802 V8_NOINLINE std::string Dump(); | 802 std::string Dump(); |
| 803 | 803 |
| 804 RuntimeCallStats() { | 804 RuntimeCallStats() { |
| 805 Reset(); | 805 Reset(); |
| 806 in_use_ = false; | 806 in_use_ = false; |
| 807 } | 807 } |
| 808 | 808 |
| 809 RuntimeCallTimer* current_timer() { return current_timer_; } | 809 RuntimeCallTimer* current_timer() { return current_timer_; } |
| 810 bool InUse() { return in_use_; } | 810 bool InUse() { return in_use_; } |
| 811 | 811 |
| 812 private: | 812 private: |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 } | 1272 } |
| 1273 | 1273 |
| 1274 Isolate* isolate_ = nullptr; | 1274 Isolate* isolate_ = nullptr; |
| 1275 RuntimeCallTimer timer_; | 1275 RuntimeCallTimer timer_; |
| 1276 }; | 1276 }; |
| 1277 | 1277 |
| 1278 } // namespace internal | 1278 } // namespace internal |
| 1279 } // namespace v8 | 1279 } // namespace v8 |
| 1280 | 1280 |
| 1281 #endif // V8_COUNTERS_H_ | 1281 #endif // V8_COUNTERS_H_ |
| OLD | NEW |