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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « cc/paint_time_counter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/paint_time_counter.h"
6
7 namespace cc {
8
9 // static
10 scoped_ptr<PaintTimeCounter> PaintTimeCounter::create() {
11 return make_scoped_ptr(new PaintTimeCounter());
12 }
13
14 PaintTimeCounter::PaintTimeCounter() {
15 }
16
17 base::TimeDelta PaintTimeCounter::GetPaintTimeOfRecentFrame(
18 const size_t& n) const {
19 DCHECK(n < ring_buffer_.BufferSize());
20
21 if (ring_buffer_.IsFilledIndex(n))
22 return ring_buffer_.ReadBuffer(n);
23
24 return base::TimeDelta();
25 }
26
27 void PaintTimeCounter::SavePaintTime(const base::TimeDelta& total_paint_time) {
28 base::TimeDelta paint_time = total_paint_time - last_total_paint_time_;
29
30 if (paint_time.InMillisecondsF() > 0)
31 ring_buffer_.SaveToBuffer(paint_time);
32
33 last_total_paint_time_ = total_paint_time;
34 }
35
36 void PaintTimeCounter::GetMinAndMaxPaintTime(base::TimeDelta* min,
37 base::TimeDelta* max) const {
38 *min = base::TimeDelta::FromDays(1);
39 *max = base::TimeDelta();
40
41 for (size_t i = 0; i < ring_buffer_.BufferSize(); i++) {
42 if (ring_buffer_.IsFilledIndex(i)) {
43 base::TimeDelta paint_time = ring_buffer_.ReadBuffer(i);
44
45 if (paint_time < *min)
46 *min = paint_time;
47 if (paint_time > *max)
48 *max = paint_time;
49 }
50 }
51
52 if (*min > *max)
53 *min = *max;
54 }
55
56 } // namespace cc
OLDNEW
« 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