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

Unified Diff: src/base/platform/elapsed-timer.h

Issue 2519073002: Revert of [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
« no previous file with comments | « no previous file | src/counters.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/platform/elapsed-timer.h
diff --git a/src/base/platform/elapsed-timer.h b/src/base/platform/elapsed-timer.h
index 2eebac481dea9b08a7de2406045ae98b21fc5053..f9a9ef43619c2650caf94bfdeefa71f969366db6 100644
--- a/src/base/platform/elapsed-timer.h
+++ b/src/base/platform/elapsed-timer.h
@@ -52,13 +52,12 @@
// and then starting the timer again, but does so in one single operation,
// avoiding the need to obtain the clock value twice. It may only be called
// on a previously started timer.
- TimeDelta Restart() { return Restart(Now()); }
-
- TimeDelta Restart(TimeTicks now) {
+ TimeDelta Restart() {
DCHECK(IsStarted());
- TimeDelta elapsed = now - start_ticks_;
+ TimeTicks ticks = Now();
+ TimeDelta elapsed = ticks - start_ticks_;
DCHECK(elapsed.InMicroseconds() >= 0);
- start_ticks_ = now;
+ start_ticks_ = ticks;
DCHECK(IsStarted());
return elapsed;
}
@@ -72,14 +71,6 @@
return elapsed;
}
- // Move the start_ticks_ to adjust the current timer.
- void Subtract(TimeDelta delta) {
- DCHECK(IsStarted());
- // If the delta is negative we want to make the elapsed time smaller, hence
- // we have to move the start_ticks_ in the opposite direction.
- start_ticks_ += delta;
- }
-
// Returns |true| if the specified |time_delta| has elapsed since the
// previous start, or |false| if not. This method may only be called on
// a previously started timer.
@@ -88,13 +79,13 @@
return Elapsed() >= time_delta;
}
+ private:
static V8_INLINE TimeTicks Now() {
TimeTicks now = TimeTicks::HighResolutionNow();
DCHECK(!now.IsNull());
return now;
}
- private:
TimeTicks start_ticks_;
#ifdef DEBUG
bool started_;
« no previous file with comments | « no previous file | src/counters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698