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

Unified Diff: src/counters-inl.h

Issue 2511093002: [counters] RuntimeStats: fix wrong bookkeeping when dynamically changing counters. (Closed)
Patch Set: adding subtime_ field on RuntimeCallTimer 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.cc ('K') | « src/counters.cc ('k') | src/log.cc » ('j') | 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..066a827a853f9620720089ec8c691067d504348a 100644
--- a/src/counters-inl.h
+++ b/src/counters-inl.h
@@ -10,6 +10,33 @@
namespace v8 {
namespace internal {
+void RuntimeCallTimer::Start(RuntimeCallCounter* counter,
+ RuntimeCallTimer* parent) {
+ counter_ = counter;
+ parent_.SetValue(parent);
+ if (FLAG_runtime_stats !=
+ v8::tracing::TracingCategoryObserver::ENABLED_BY_SAMPLING) {
+ timer_.Start();
+ }
+}
+
+RuntimeCallTimer* RuntimeCallTimer::Stop() {
+ if (!timer_.IsStarted()) return parent();
+ base::TimeDelta delta = timer_.Elapsed();
+ timer_.Stop();
+
+ counter_->Increment();
+ AddAndSubmitResults(delta);
+
+ RuntimeCallTimer* parent_timer = parent();
+ if (parent_timer) {
+ // Subtract the elapsed time from the parent to correctly calculate its own
+ // time.
+ parent_timer->SubtractSubtime(delta);
+ }
+ return parent_timer;
+}
+
RuntimeCallTimerScope::RuntimeCallTimerScope(
Isolate* isolate, RuntimeCallStats::CounterId counter_id) {
if (V8_UNLIKELY(FLAG_runtime_stats)) {
« src/counters.cc ('K') | « src/counters.cc ('k') | src/log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698