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.
5 #include "base/values.h"
6 #include "cc/debug/rendering_stats.h"
10 MainThreadRenderingStats::MainThreadRenderingStats()
11 : animation_frame_count(0),
12 screen_frame_count(0),
14 painted_pixel_count(0),
15 recorded_pixel_count(0),
16 image_gathering_count(0) {}
18 ImplThreadRenderingStats::ImplThreadRenderingStats()
19 : screen_frame_count(0),
20 dropped_frame_count(0),
21 rasterized_pixel_count(0),
22 impl_thread_scroll_count(0),
23 main_thread_scroll_count(0),
25 missing_tile_count(0),
26 deferred_image_decode_count(0),
27 deferred_image_cache_hit_count(0),
28 tile_analysis_count(0),
29 solid_color_tile_analysis_count(0) {}
31 void RenderingStats::EnumerateFields(Enumerator
* enumerator
) const {
32 enumerator
->AddInt64("numAnimationFrames",
33 main_stats
.animation_frame_count
);
34 enumerator
->AddInt64("numFramesSentToScreen", main_stats
.screen_frame_count
+
35 impl_stats
.screen_frame_count
);
36 enumerator
->AddDouble("totalPaintTimeInSeconds",
37 main_stats
.paint_time
.InSecondsF());
38 enumerator
->AddDouble("totalRecordTimeInSeconds",
39 main_stats
.record_time
.InSecondsF());
40 enumerator
->AddDouble("totalBestRecordTimeInSeconds",
41 main_stats
.best_record_time
.InSecondsF());
42 enumerator
->AddDouble("totalCommitTimeInSeconds",
43 main_stats
.commit_time
.InSecondsF());
44 enumerator
->AddInt64("totalCommitCount", main_stats
.commit_count
);
45 enumerator
->AddInt64("totalPixelsPainted", main_stats
.painted_pixel_count
);
46 enumerator
->AddInt64("totalPixelsRecorded", main_stats
.recorded_pixel_count
);
47 enumerator
->AddInt64("totalImageGatheringCount",
48 main_stats
.image_gathering_count
);
49 enumerator
->AddDouble("totalImageGatheringTimeInSeconds",
50 main_stats
.image_gathering_time
.InSecondsF());
51 enumerator
->AddInt64("droppedFrameCount", impl_stats
.dropped_frame_count
);
52 enumerator
->AddDouble("totalRasterizeTimeInSeconds",
53 impl_stats
.rasterize_time
.InSecondsF());
54 enumerator
->AddDouble(
55 "totalRasterizeTimeForNowBinsOnPendingTree",
56 impl_stats
.rasterize_time_for_now_bins_on_pending_tree
.InSecondsF());
57 enumerator
->AddDouble("bestRasterizeTimeInSeconds",
58 impl_stats
.best_rasterize_time
.InSecondsF());
59 enumerator
->AddInt64("totalPixelsRasterized",
60 impl_stats
.rasterized_pixel_count
);
61 enumerator
->AddInt64("numImplThreadScrolls",
62 impl_stats
.impl_thread_scroll_count
);
63 enumerator
->AddInt64("numMainThreadScrolls",
64 impl_stats
.main_thread_scroll_count
);
65 enumerator
->AddInt64("numLayersDrawn", impl_stats
.drawn_layer_count
);
66 enumerator
->AddInt64("numMissingTiles", impl_stats
.missing_tile_count
);
67 enumerator
->AddInt64("totalDeferredImageDecodeCount",
68 impl_stats
.deferred_image_decode_count
);
69 enumerator
->AddInt64("totalTilesAnalyzed", impl_stats
.tile_analysis_count
);
70 enumerator
->AddInt64("solidColorTilesAnalyzed",
71 impl_stats
.solid_color_tile_analysis_count
);
72 enumerator
->AddInt64("totalDeferredImageCacheHitCount",
73 impl_stats
.deferred_image_cache_hit_count
);
74 enumerator
->AddDouble("totalDeferredImageDecodeTimeInSeconds",
75 impl_stats
.deferred_image_decode_time
.InSecondsF());
76 enumerator
->AddDouble("totalTileAnalysisTimeInSeconds",
77 impl_stats
.tile_analysis_time
.InSecondsF());
80 void MainThreadRenderingStats::IssueTraceEvent() const {
81 TRACE_EVENT_INSTANT1("benchmark",
82 "MainThreadRenderingStats::IssueTraceEvent",
83 TRACE_EVENT_SCOPE_THREAD
,
84 "data", AsTraceableData());
87 scoped_ptr
<base::debug::ConvertableToTraceFormat
>
88 MainThreadRenderingStats::AsTraceableData() const {
89 scoped_ptr
<base::DictionaryValue
> record_data(new base::DictionaryValue());
90 record_data
->SetInteger("animation_frame_count",
91 animation_frame_count
);
92 record_data
->SetInteger("screen_frame_count",
94 record_data
->SetDouble("paint_time",
95 paint_time
.InSecondsF());
96 record_data
->SetDouble("record_time",
97 record_time
.InSecondsF());
98 record_data
->SetDouble("best_record_time",
99 best_record_time
.InSecondsF());
100 record_data
->SetDouble("commit_time",
101 commit_time
.InSecondsF());
102 record_data
->SetInteger("commit_count",
104 record_data
->SetInteger("painted_pixel_count",
105 painted_pixel_count
);
106 record_data
->SetInteger("recorded_pixel_count",
107 recorded_pixel_count
);
108 record_data
->SetInteger("image_gathering_count",
109 image_gathering_count
);
110 record_data
->SetDouble("image_gathering_time",
111 image_gathering_time
.InSecondsF());
112 return TracedValue::FromValue(record_data
.release());
115 void ImplThreadRenderingStats::IssueTraceEvent() const {
116 TRACE_EVENT_INSTANT1("benchmark",
117 "ImplThreadRenderingStats::IssueTraceEvent",
118 TRACE_EVENT_SCOPE_THREAD
,
119 "data", AsTraceableData());
122 scoped_ptr
<base::debug::ConvertableToTraceFormat
>
123 ImplThreadRenderingStats::AsTraceableData() const {
124 scoped_ptr
<base::DictionaryValue
> record_data(new base::DictionaryValue());
125 record_data
->SetInteger("screen_frame_count",
127 record_data
->SetInteger("dropped_frame_count",
128 dropped_frame_count
);
129 record_data
->SetDouble("rasterize_time",
130 rasterize_time
.InSecondsF());
131 record_data
->SetDouble(
132 "rasterize_time_for_now_bins_on_pending_tree",
133 rasterize_time_for_now_bins_on_pending_tree
.InSecondsF());
134 record_data
->SetDouble("best_rasterize_time",
135 best_rasterize_time
.InSecondsF());
136 record_data
->SetInteger("rasterized_pixel_count",
137 rasterized_pixel_count
);
138 record_data
->SetInteger("impl_thread_scroll_count",
139 impl_thread_scroll_count
);
140 record_data
->SetInteger("main_thread_scroll_count",
141 main_thread_scroll_count
);
142 record_data
->SetInteger("drawn_layer_count",
144 record_data
->SetInteger("missing_tile_count",
146 record_data
->SetInteger("deferred_image_decode_count",
147 deferred_image_decode_count
);
148 record_data
->SetInteger("deferred_image_cache_hit_count",
149 deferred_image_cache_hit_count
);
150 record_data
->SetInteger("tile_analysis_count",
151 tile_analysis_count
);
152 record_data
->SetInteger("solid_color_tile_analysis_count",
153 solid_color_tile_analysis_count
);
154 record_data
->SetDouble("deferred_image_decode_time",
155 deferred_image_decode_time
.InSecondsF());
156 record_data
->SetDouble("tile_analysis_time",
157 tile_analysis_time
.InSecondsF());
158 return TracedValue::FromValue(record_data
.release());
162 void MainThreadRenderingStats::Add(const MainThreadRenderingStats
& other
) {
163 animation_frame_count
+= other
.animation_frame_count
;
164 screen_frame_count
+= other
.screen_frame_count
;
165 paint_time
+= other
.paint_time
;
166 record_time
+= other
.record_time
;
167 best_record_time
+= other
.best_record_time
;
168 commit_time
+= other
.commit_time
;
169 commit_count
+= other
.commit_count
;
170 painted_pixel_count
+= other
.painted_pixel_count
;
171 recorded_pixel_count
+= other
.recorded_pixel_count
;
172 image_gathering_count
+= other
.image_gathering_count
;
173 image_gathering_time
+= other
.image_gathering_time
;
176 void ImplThreadRenderingStats::Add(const ImplThreadRenderingStats
& other
) {
177 screen_frame_count
+= other
.screen_frame_count
;
178 dropped_frame_count
+= other
.dropped_frame_count
;
179 rasterize_time
+= other
.rasterize_time
;
180 rasterize_time_for_now_bins_on_pending_tree
+=
181 other
.rasterize_time_for_now_bins_on_pending_tree
;
182 best_rasterize_time
+= other
.best_rasterize_time
;
183 rasterized_pixel_count
+= other
.rasterized_pixel_count
;
184 impl_thread_scroll_count
+= other
.impl_thread_scroll_count
;
185 main_thread_scroll_count
+= other
.main_thread_scroll_count
;
186 drawn_layer_count
+= other
.drawn_layer_count
;
187 missing_tile_count
+= other
.missing_tile_count
;
188 deferred_image_decode_count
+= other
.deferred_image_decode_count
;
189 deferred_image_cache_hit_count
+= other
.deferred_image_cache_hit_count
;
190 deferred_image_decode_time
+= other
.deferred_image_decode_time
;
191 tile_analysis_count
+= other
.tile_analysis_count
;
192 solid_color_tile_analysis_count
+= other
.solid_color_tile_analysis_count
;
193 tile_analysis_time
+= other
.tile_analysis_time
;
196 void RenderingStats::Add(const RenderingStats
& other
) {
197 main_stats
.Add(other
.main_stats
);
198 impl_stats
.Add(other
.impl_stats
);