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

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: updated to new RingBuffer 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
« cc/paint_time_counter.h ('K') | « 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 #include <limits>
8
9 namespace cc {
10
11 // static
12 scoped_ptr<PaintTimeCounter> PaintTimeCounter::create() {
13 return make_scoped_ptr(new PaintTimeCounter());
14 }
15
16 PaintTimeCounter::PaintTimeCounter() {
17 }
18
19 double PaintTimeCounter::GetPaintTimeOfRecentFrame(int n) const {
20 DCHECK(n >= 0);
21 DCHECK(n < ring_buffer_.BufferSize());
22
23 if (ring_buffer_.IsFilledIndex(n))
24 return ring_buffer_.ReadBuffer(n);
25
26 return 0;
27 }
28
29 void PaintTimeCounter::SavePaintTime(double total_paint_time) {
30 double paint_time = total_paint_time - last_paint_time_;
31
32 if (paint_time > 0)
33 ring_buffer_.SaveToBuffer(paint_time);
34
35 last_paint_time_ = total_paint_time;
36 }
37
38 void PaintTimeCounter::GetMinAndMaxPaintTime(double& min, double& max) const {
reveman 2013/01/11 16:10:49 chromium style doesn't allow using references for
39 min = std::numeric_limits<double>::max();
40 max = 0;
41
42 for (int i = ring_buffer_.BufferSize() - 1; i > 0 && ring_buffer_.IsFilledInde x(i); --i) {
reveman 2013/01/11 16:10:49 nit: lines should not be >= 80 characters.
danakj 2013/01/11 16:39:09 s/>=/>/ "Each line of text in your code should be
43 double paint_time = ring_buffer_.ReadBuffer(i);
44 min = std::min(paint_time, min);
45 max = std::max(paint_time, max);
46 }
47
48 if (min > max)
49 min = max;
50 }
51
52 } // namespace cc
OLDNEW
« cc/paint_time_counter.h ('K') | « cc/paint_time_counter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698