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

Side by Side Diff: cc/paint_time_counter.cc

Issue 12209022: cc: add rasterize time to continuous painting graph data in impl-side-painting (Closed) Base URL: http://git.chromium.org/chromium/src.git@raster
Patch Set: Save paint and rasterize time in per frame struct Created 7 years, 10 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/paint_time_counter.h" 5 #include "cc/paint_time_counter.h"
6 6
7 namespace cc { 7 namespace cc {
8 8
9 // static 9 // static
10 scoped_ptr<PaintTimeCounter> PaintTimeCounter::create() { 10 scoped_ptr<PaintTimeCounter> PaintTimeCounter::create() {
11 return make_scoped_ptr(new PaintTimeCounter()); 11 return make_scoped_ptr(new PaintTimeCounter());
12 } 12 }
13 13
14 PaintTimeCounter::PaintTimeCounter() { 14 PaintTimeCounter::PaintTimeCounter()
15 : ignore_next_paint_time_(true),
16 ignore_next_rasterize_time_(true) {
15 } 17 }
16 18
17 base::TimeDelta PaintTimeCounter::GetPaintTimeOfRecentFrame( 19 base::TimeDelta PaintTimeCounter::GetPaintTimeOfRecentFrame(
18 const size_t& n) const { 20 const size_t& n) const {
19 DCHECK(n < ring_buffer_.BufferSize()); 21 DCHECK(n < ring_buffer_.BufferSize());
20 22
21 if (ring_buffer_.IsFilledIndex(n)) 23 if (ring_buffer_.IsFilledIndex(n))
22 return ring_buffer_.ReadBuffer(n); 24 return ring_buffer_.ReadBuffer(n).time();
23 25
24 return base::TimeDelta(); 26 return base::TimeDelta();
25 } 27 }
26 28
27 void PaintTimeCounter::SavePaintTime(const base::TimeDelta& total_paint_time) { 29 void PaintTimeCounter::SavePaintTime(const base::TimeDelta& total_paint_time,
28 base::TimeDelta paint_time = total_paint_time - last_total_paint_time_; 30 const int& frame_number) {
29 31 if (!ignore_next_paint_time_)
30 if (paint_time.InMillisecondsF() > 0) 32 GetEntryForFrame(frame_number).paint_time =
31 ring_buffer_.SaveToBuffer(paint_time); 33 total_paint_time - last_total_paint_time_;
32 34
33 last_total_paint_time_ = total_paint_time; 35 last_total_paint_time_ = total_paint_time;
36 ignore_next_paint_time_ = false;
37 }
38
39 void PaintTimeCounter::SaveRasterizeTime(
40 const base::TimeDelta& total_rasterize_time,
41 const int& frame_number) {
42 if (!ignore_next_rasterize_time_)
nduca 2013/02/13 08:12:21 since this is just for the first entry in the ring
43 GetEntryForFrame(frame_number).rasterize_time =
nduca 2013/02/13 08:12:21 Oh, i just realized.... So! The sequence in wallt
44 total_rasterize_time - last_total_rasterize_time_;
45
46 last_total_rasterize_time_ = total_rasterize_time;
47 ignore_next_rasterize_time_ = false;
34 } 48 }
35 49
36 void PaintTimeCounter::GetMinAndMaxPaintTime(base::TimeDelta* min, 50 void PaintTimeCounter::GetMinAndMaxPaintTime(base::TimeDelta* min,
37 base::TimeDelta* max) const { 51 base::TimeDelta* max) const {
38 *min = base::TimeDelta::FromDays(1); 52 *min = base::TimeDelta::FromDays(1);
39 *max = base::TimeDelta(); 53 *max = base::TimeDelta();
40 54
41 for (size_t i = 0; i < ring_buffer_.BufferSize(); i++) { 55 for (size_t i = 0; i < ring_buffer_.BufferSize(); i++) {
42 if (ring_buffer_.IsFilledIndex(i)) { 56 if (ring_buffer_.IsFilledIndex(i)) {
43 base::TimeDelta paint_time = ring_buffer_.ReadBuffer(i); 57 base::TimeDelta paint_time = ring_buffer_.ReadBuffer(i).time();
44 58
45 if (paint_time < *min) 59 if (paint_time < *min)
46 *min = paint_time; 60 *min = paint_time;
47 if (paint_time > *max) 61 if (paint_time > *max)
48 *max = paint_time; 62 *max = paint_time;
49 } 63 }
50 } 64 }
51 65
52 if (*min > *max) 66 if (*min > *max)
53 *min = *max; 67 *min = *max;
54 } 68 }
55 69
70 void PaintTimeCounter::ClearHistory() {
71 ring_buffer_.Clear();
72 ignore_next_paint_time_ = true;
73 ignore_next_rasterize_time_ = true;
74 }
75
76 PaintTimeCounter::Entry& PaintTimeCounter::GetEntryForFrame(
nduca 2013/02/13 08:12:21 GetOrCreateEntryForFrame since it adds it if it do
77 const int& frame_number) {
78 for (size_t i = 0; i < ring_buffer_.BufferSize(); i++) {
79 if (ring_buffer_.IsFilledIndex(i) &&
egraether 2013/02/12 00:15:30 Buffer iteration is a mess. I will try to implemen
80 ring_buffer_.ReadBuffer(i).frame_number == frame_number)
81 return ring_buffer_.MutableReadBuffer(i);
82 }
83
84 Entry entry;
85 entry.frame_number = frame_number;
86 ring_buffer_.SaveToBuffer(entry);
87 return ring_buffer_.MutableReadBuffer(ring_buffer_.BufferSize() - 1);
88 }
89
56 } // namespace cc 90 } // namespace cc
OLDNEW
« cc/layer_tree_host_impl.cc ('K') | « cc/paint_time_counter.h ('k') | cc/rendering_stats.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698