5 #ifndef V8_COUNTERS_INL_H_ 6 #define V8_COUNTERS_INL_H_ 8 #include "src/counters.h" 13 void RuntimeCallTimer::Start(RuntimeCallCounter* counter,
14 RuntimeCallTimer* parent) {
17 parent_.SetValue(parent);
18 if (base::AsAtomic32::Relaxed_Load(&FLAG_runtime_stats) ==
19 v8::tracing::TracingCategoryObserver::ENABLED_BY_SAMPLING) {
22 base::TimeTicks now = RuntimeCallTimer::Now();
23 if (parent) parent->Pause(now);
28 void RuntimeCallTimer::Pause(base::TimeTicks now) {
30 elapsed_ += (now - start_ticks_);
31 start_ticks_ = base::TimeTicks();
34 void RuntimeCallTimer::Resume(base::TimeTicks now) {
39 RuntimeCallTimer* RuntimeCallTimer::Stop() {
40 if (!IsStarted())
return parent();
41 base::TimeTicks now = RuntimeCallTimer::Now();
43 counter_->Increment();
44 CommitTimeToCounter();
46 RuntimeCallTimer* parent_timer = parent();
48 parent_timer->Resume(now);
53 void RuntimeCallTimer::CommitTimeToCounter() {
54 counter_->Add(elapsed_);
55 elapsed_ = base::TimeDelta();
58 bool RuntimeCallTimer::IsStarted() {
return start_ticks_ != base::TimeTicks(); }
60 RuntimeCallTimerScope::RuntimeCallTimerScope(Isolate* isolate,
61 HeapObject* heap_object,
62 RuntimeCallCounterId counter_id)
63 : RuntimeCallTimerScope(isolate, counter_id) {}
68 #endif // V8_COUNTERS_INL_H_