| 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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 | 485 |
| 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(RuntimeCallCounter* counter, RuntimeCallTimer* parent) | 495 inline void Initialize(RuntimeCallCounter* counter, |
| 496 : counter_(counter), parent_(parent) {} | 496 RuntimeCallTimer* parent) { |
| 497 counter_ = counter; |
| 498 parent_ = parent; |
| 499 } |
| 497 | 500 |
| 498 inline void Start() { | 501 inline void Start() { |
| 499 timer_.Start(); | 502 timer_.Start(); |
| 500 counter_->count++; | 503 counter_->count++; |
| 501 } | 504 } |
| 502 | 505 |
| 503 inline RuntimeCallTimer* Stop() { | 506 inline RuntimeCallTimer* Stop() { |
| 504 base::TimeDelta delta = timer_.Elapsed(); | 507 base::TimeDelta delta = timer_.Elapsed(); |
| 505 counter_->time += delta; | 508 counter_->time += delta; |
| 506 if (parent_ != NULL) { | 509 if (parent_ != NULL) { |
| 507 parent_->AdjustForSubTimer(delta); | 510 parent_->AdjustForSubTimer(delta); |
| 508 } | 511 } |
| 509 return parent_; | 512 return parent_; |
| 510 } | 513 } |
| 511 | 514 |
| 512 void AdjustForSubTimer(base::TimeDelta delta) { counter_->time -= delta; } | 515 inline void AdjustForSubTimer(base::TimeDelta delta) { |
| 516 counter_->time -= delta; |
| 517 } |
| 513 | 518 |
| 514 private: | 519 private: |
| 515 RuntimeCallCounter* counter_; | 520 RuntimeCallCounter* counter_; |
| 516 RuntimeCallTimer* parent_; | 521 RuntimeCallTimer* parent_; |
| 517 base::ElapsedTimer timer_; | 522 base::ElapsedTimer timer_; |
| 518 }; | 523 }; |
| 519 | 524 |
| 520 struct RuntimeCallStats { | 525 struct RuntimeCallStats { |
| 521 // Dummy counter for the unexpected stub miss. | 526 // Dummy counter for the unexpected stub miss. |
| 522 RuntimeCallCounter UnexpectedStubMiss = | 527 RuntimeCallCounter UnexpectedStubMiss = |
| (...skipping 27 matching lines...) Expand all Loading... |
| 550 void Reset(); | 555 void Reset(); |
| 551 void Print(std::ostream& os); | 556 void Print(std::ostream& os); |
| 552 | 557 |
| 553 RuntimeCallStats() { Reset(); } | 558 RuntimeCallStats() { Reset(); } |
| 554 }; | 559 }; |
| 555 | 560 |
| 556 // A RuntimeCallTimerScopes wraps around a RuntimeCallTimer to measure the | 561 // A RuntimeCallTimerScopes wraps around a RuntimeCallTimer to measure the |
| 557 // the time of C++ scope. | 562 // the time of C++ scope. |
| 558 class RuntimeCallTimerScope { | 563 class RuntimeCallTimerScope { |
| 559 public: | 564 public: |
| 560 explicit RuntimeCallTimerScope(Isolate* isolate, RuntimeCallCounter* counter); | 565 inline explicit RuntimeCallTimerScope(Isolate* isolate, |
| 561 ~RuntimeCallTimerScope(); | 566 RuntimeCallCounter* counter) { |
| 567 if (FLAG_runtime_call_stats) Enter(isolate, counter); |
| 568 } |
| 569 inline ~RuntimeCallTimerScope() { |
| 570 if (FLAG_runtime_call_stats) Leave(); |
| 571 } |
| 572 |
| 573 void Enter(Isolate* isolate, RuntimeCallCounter* counter); |
| 574 void Leave(); |
| 562 | 575 |
| 563 private: | 576 private: |
| 564 Isolate* isolate_; | 577 Isolate* isolate_; |
| 565 RuntimeCallTimer timer_; | 578 RuntimeCallTimer timer_; |
| 566 }; | 579 }; |
| 567 | 580 |
| 568 #define HISTOGRAM_RANGE_LIST(HR) \ | 581 #define HISTOGRAM_RANGE_LIST(HR) \ |
| 569 /* Generic range histograms */ \ | 582 /* Generic range histograms */ \ |
| 570 HR(detached_context_age_in_gc, V8.DetachedContextAgeInGC, 0, 20, 21) \ | 583 HR(detached_context_age_in_gc, V8.DetachedContextAgeInGC, 0, 20, 21) \ |
| 571 HR(gc_idle_time_allotted_in_ms, V8.GCIdleTimeAllottedInMS, 0, 10000, 101) \ | 584 HR(gc_idle_time_allotted_in_ms, V8.GCIdleTimeAllottedInMS, 0, 10000, 101) \ |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 | 976 |
| 964 explicit Counters(Isolate* isolate); | 977 explicit Counters(Isolate* isolate); |
| 965 | 978 |
| 966 DISALLOW_IMPLICIT_CONSTRUCTORS(Counters); | 979 DISALLOW_IMPLICIT_CONSTRUCTORS(Counters); |
| 967 }; | 980 }; |
| 968 | 981 |
| 969 } // namespace internal | 982 } // namespace internal |
| 970 } // namespace v8 | 983 } // namespace v8 |
| 971 | 984 |
| 972 #endif // V8_COUNTERS_H_ | 985 #endif // V8_COUNTERS_H_ |
| OLD | NEW |