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

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 use base::TimeDelta 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 base::TimeDelta PaintTimeCounter::GetPaintTimeOfRecentFrame(const size_t& n) con st {
reveman 2013/01/16 22:48:04 nit: line not <= 80 characters long.
20 DCHECK(n < ring_buffer_.BufferSize());
21
22 if (ring_buffer_.IsFilledIndex(n))
23 return ring_buffer_.ReadBuffer(n);
24
25 return base::TimeDelta();
26 }
27
28 void PaintTimeCounter::SavePaintTime(const base::TimeDelta& total_paint_time) {
29 base::TimeDelta paint_time = total_paint_time - last_total_paint_time_;
30
31 if (paint_time.InMillisecondsF() > 0)
32 ring_buffer_.SaveToBuffer(paint_time);
33
34 last_total_paint_time_ = total_paint_time;
35 }
36
37 void PaintTimeCounter::GetMinAndMaxPaintTimeInMilliseconds(double* min, double* max) const {
reveman 2013/01/16 22:48:04 nit: line not <= 80 characters long.
38 *min = std::numeric_limits<double>::max();
39 *max = 0;
40
41 for (size_t i = 0; i < ring_buffer_.BufferSize(); i++) {
egraether 2013/01/16 19:31:56 Loops in increasing direction because the iterator
42 if (ring_buffer_.IsFilledIndex(i)) {
43 double paint_time = ring_buffer_.ReadBuffer(i).InMillisecondsF();
44 *min = std::min(paint_time, *min);
45 *max = std::max(paint_time, *max);
46 }
47 }
48
49 if (*min > *max)
50 *min = *max;
51 }
52
53 } // 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