summaryrefslogtreecommitdiffstats
path: root/cc/debug/paint_time_counter.h
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-18 06:54:27 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-18 06:54:27 +0000
commit6e84de2e71a4d6c9652ba3dd4471ff4f45ac8b27 (patch)
tree2d9eaa933544f87303d9cfb552c72fd96eb2a1a3 /cc/debug/paint_time_counter.h
parent0fc818ec6e012243303de3e013037c8c0221c83f (diff)
downloadchromium_src-6e84de2e71a4d6c9652ba3dd4471ff4f45ac8b27.zip
chromium_src-6e84de2e71a4d6c9652ba3dd4471ff4f45ac8b27.tar.gz
chromium_src-6e84de2e71a4d6c9652ba3dd4471ff4f45ac8b27.tar.bz2
Part 2 of cc/ directory shuffles: debug
Continuation of https://src.chromium.org/viewvc/chrome?view=rev&revision=188681 BUG=190824 TBR=enne@chromium.org Review URL: https://codereview.chromium.org/12648008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188685 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/debug/paint_time_counter.h')
-rw-r--r--cc/debug/paint_time_counter.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/cc/debug/paint_time_counter.h b/cc/debug/paint_time_counter.h
new file mode 100644
index 0000000..a195083
--- /dev/null
+++ b/cc/debug/paint_time_counter.h
@@ -0,0 +1,67 @@
+// Copyright 2013 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.
+
+#ifndef CC_DEBUG_PAINT_TIME_COUNTER_H_
+#define CC_DEBUG_PAINT_TIME_COUNTER_H_
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/time.h"
+#include "cc/debug/ring_buffer.h"
+
+namespace cc {
+
+// Maintains a history of paint times for each frame
+class PaintTimeCounter {
+ public:
+ static scoped_ptr<PaintTimeCounter> Create();
+
+ size_t HistorySize() const { return ring_buffer_.BufferSize(); }
+
+ struct Entry {
+ Entry()
+ : commit_number(0) {}
+
+ int commit_number;
+ base::TimeDelta paint_time;
+ base::TimeDelta rasterize_time;
+
+ base::TimeDelta total_time() const {
+ return paint_time + rasterize_time;
+ }
+ };
+
+ // n = 0 returns the oldest and
+ // n = PaintTimeHistorySize() - 1 the most recent paint time.
+ base::TimeDelta GetPaintTimeOfRecentFrame(const size_t& n) const;
+
+ void SavePaintTime(const base::TimeDelta& total_paint_time,
+ int commit_number);
+ void SaveRasterizeTime(const base::TimeDelta& total_rasterize_time,
+ int commit_number);
+ void GetMinAndMaxPaintTime(base::TimeDelta* min, base::TimeDelta* max) const;
+
+ void ClearHistory();
+
+ typedef RingBuffer<Entry, 200> RingBufferType;
+ RingBufferType::Iterator Begin() const { return ring_buffer_.Begin(); }
+ RingBufferType::Iterator End() const { return ring_buffer_.End(); }
+
+ private:
+ PaintTimeCounter();
+
+ RingBufferType ring_buffer_;
+
+ base::TimeDelta last_total_paint_time_;
+ base::TimeDelta last_total_rasterize_time_;
+
+ bool can_save_paint_time_delta_;
+ bool can_save_rasterize_time_delta_;
+
+ DISALLOW_COPY_AND_ASSIGN(PaintTimeCounter);
+};
+
+} // namespace cc
+
+#endif // CC_DEBUG_PAINT_TIME_COUNTER_H_