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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 const char* name; | 486 const char* name; |
487 int64_t count = 0; | 487 int64_t count = 0; |
488 base::TimeDelta time; | 488 base::TimeDelta time; |
489 }; | 489 }; |
490 | 490 |
491 // RuntimeCallTimer is used to keep track of the stack of currently active | 491 // RuntimeCallTimer is used to keep track of the stack of currently active |
492 // timers used for properly measuring the own time of a RuntimeCallCounter. | 492 // timers used for properly measuring the own time of a RuntimeCallCounter. |
493 class RuntimeCallTimer { | 493 class RuntimeCallTimer { |
494 public: | 494 public: |
495 RuntimeCallTimer() {} | 495 RuntimeCallTimer() {} |
| 496 RuntimeCallCounter* counter() { return counter_; } |
| 497 base::ElapsedTimer timer() { return timer_; } |
496 | 498 |
497 private: | 499 private: |
498 friend class RuntimeCallStats; | 500 friend class RuntimeCallStats; |
499 | 501 |
500 inline void Start(RuntimeCallCounter* counter, RuntimeCallTimer* parent) { | 502 inline void Start(RuntimeCallCounter* counter, RuntimeCallTimer* parent) { |
501 counter_ = counter; | 503 counter_ = counter; |
502 parent_ = parent; | 504 parent_ = parent; |
503 timer_.Start(); | 505 timer_.Start(); |
504 } | 506 } |
505 | 507 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 static void Leave(Isolate* isolate, RuntimeCallTimer* timer); | 770 static void Leave(Isolate* isolate, RuntimeCallTimer* timer); |
769 | 771 |
770 // Set counter id for the innermost measurement. It can be used to refine | 772 // Set counter id for the innermost measurement. It can be used to refine |
771 // event kind when a runtime entry counter is too generic. | 773 // event kind when a runtime entry counter is too generic. |
772 static void CorrectCurrentCounterId(Isolate* isolate, CounterId counter_id); | 774 static void CorrectCurrentCounterId(Isolate* isolate, CounterId counter_id); |
773 | 775 |
774 void Reset(); | 776 void Reset(); |
775 void Print(std::ostream& os); | 777 void Print(std::ostream& os); |
776 | 778 |
777 RuntimeCallStats() { Reset(); } | 779 RuntimeCallStats() { Reset(); } |
| 780 RuntimeCallTimer* current_timer() { return current_timer_; } |
778 | 781 |
779 private: | 782 private: |
780 // Counter to track recursive time events. | 783 // Counter to track recursive time events. |
781 RuntimeCallTimer* current_timer_ = NULL; | 784 RuntimeCallTimer* current_timer_ = NULL; |
782 }; | 785 }; |
783 | 786 |
784 #define TRACE_RUNTIME_CALL_STATS(isolate, counter_name) \ | 787 #define TRACE_RUNTIME_CALL_STATS(isolate, counter_name) \ |
785 do { \ | 788 do { \ |
786 if (FLAG_runtime_call_stats) { \ | 789 if (FLAG_runtime_call_stats) { \ |
787 RuntimeCallStats::CorrectCurrentCounterId( \ | 790 RuntimeCallStats::CorrectCurrentCounterId( \ |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 | 1234 |
1232 explicit Counters(Isolate* isolate); | 1235 explicit Counters(Isolate* isolate); |
1233 | 1236 |
1234 DISALLOW_IMPLICIT_CONSTRUCTORS(Counters); | 1237 DISALLOW_IMPLICIT_CONSTRUCTORS(Counters); |
1235 }; | 1238 }; |
1236 | 1239 |
1237 } // namespace internal | 1240 } // namespace internal |
1238 } // namespace v8 | 1241 } // namespace v8 |
1239 | 1242 |
1240 #endif // V8_COUNTERS_H_ | 1243 #endif // V8_COUNTERS_H_ |
OLD | NEW |