Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: src/counters-inl.h

Issue 2511093002: [counters] RuntimeStats: fix wrong bookkeeping when dynamically changing counters. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/counters.h ('K') | « src/counters.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/counters-inl.h
diff --git a/src/counters-inl.h b/src/counters-inl.h
index 7219ef778a6ea6a06ce25ad457b7a1299c5d7194..c0a6f378902fc1fca30468722671a19d4c1a0020 100644
--- a/src/counters-inl.h
+++ b/src/counters-inl.h
@@ -10,6 +10,47 @@
namespace v8 {
namespace internal {
+inline void RuntimeCallTimer::Start(RuntimeCallCounter* counter,
+ RuntimeCallTimer* parent) {
+ counter_ = counter;
+ parent_.SetValue(parent);
+ if (FLAG_runtime_stats !=
+ v8::tracing::TracingCategoryObserver::ENABLED_BY_SAMPLING) {
+ timer_.Start();
+ }
+}
+
+inline RuntimeCallTimer* RuntimeCallTimer::Stop() {
+ if (!timer_.IsStarted()) return parent();
+ base::TimeDelta delta = timer_.Elapsed();
+ timer_.Stop();
+ counter_->count++;
+ counter_->time += delta;
+ if (parent()) {
+ // Adjust parent timer so that it does not include sub timer's time.
+ parent()->Subtract(delta);
Camillo Bruni 2016/11/17 14:02:00 newly added Subtract
+ }
+ return parent();
+}
+
+inline void RuntimeCallTimer::Subtract(base::TimeDelta delta) {
+ // Adjust the current timer instead of directly subtracting the sub-timers
+ // from the current counter. This way we can easily the counter of an active
Igor Sheludko 2016/11/18 09:55:45 .. can easily [change?] the counter of ...
+ // timer scope. Otherwise we would end up subtracting the time from the
+ // previous counter and add the own time to the newly changed counter.
+ timer_.AdjustBy(-delta);
+}
+
+inline void RuntimeCallTimer::Elapsed() {
+ base::TimeDelta delta = timer_.Elapsed();
+ counter_->time += delta;
+ if (parent()) {
+ parent()->counter_->time -= delta;
+ parent()->Elapsed();
+ }
+ timer_.Restart();
+}
+
RuntimeCallTimerScope::RuntimeCallTimerScope(
Isolate* isolate, RuntimeCallStats::CounterId counter_id) {
if (V8_UNLIKELY(FLAG_runtime_stats)) {
« src/counters.h ('K') | « src/counters.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698