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

Unified Diff: cc/paint_time_counter.cc

Issue 11827009: cc: add PaintTimeCounter to keep track of per frame paint time (Closed) Base URL: http://git.chromium.org/chromium/src.git@ring
Patch Set: resolved nits, TimeDelta throughout the API Created 7 years, 11 months 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 | « cc/paint_time_counter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/paint_time_counter.cc
diff --git a/cc/paint_time_counter.cc b/cc/paint_time_counter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..25b1bc677e9a7829cdf844a75d5c17588deeb5d4
--- /dev/null
+++ b/cc/paint_time_counter.cc
@@ -0,0 +1,56 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/paint_time_counter.h"
+
+namespace cc {
+
+// static
+scoped_ptr<PaintTimeCounter> PaintTimeCounter::create() {
+ return make_scoped_ptr(new PaintTimeCounter());
+}
+
+PaintTimeCounter::PaintTimeCounter() {
+}
+
+base::TimeDelta PaintTimeCounter::GetPaintTimeOfRecentFrame(
+ const size_t& n) const {
+ DCHECK(n < ring_buffer_.BufferSize());
+
+ if (ring_buffer_.IsFilledIndex(n))
+ return ring_buffer_.ReadBuffer(n);
+
+ return base::TimeDelta();
+}
+
+void PaintTimeCounter::SavePaintTime(const base::TimeDelta& total_paint_time) {
+ base::TimeDelta paint_time = total_paint_time - last_total_paint_time_;
+
+ if (paint_time.InMillisecondsF() > 0)
+ ring_buffer_.SaveToBuffer(paint_time);
+
+ last_total_paint_time_ = total_paint_time;
+}
+
+void PaintTimeCounter::GetMinAndMaxPaintTime(base::TimeDelta* min,
+ base::TimeDelta* max) const {
+ *min = base::TimeDelta::FromDays(1);
+ *max = base::TimeDelta();
+
+ for (size_t i = 0; i < ring_buffer_.BufferSize(); i++) {
+ if (ring_buffer_.IsFilledIndex(i)) {
+ base::TimeDelta paint_time = ring_buffer_.ReadBuffer(i);
+
+ if (paint_time < *min)
+ *min = paint_time;
+ if (paint_time > *max)
+ *max = paint_time;
+ }
+ }
+
+ if (*min > *max)
+ *min = *max;
+}
+
+} // namespace cc
« no previous file with comments | « cc/paint_time_counter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698