| OLD | NEW |
| 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 "base/values.h" | 5 #include "base/values.h" |
| 6 #include "cc/debug/rendering_stats.h" | 6 #include "cc/debug/rendering_stats.h" |
| 7 | 7 |
| 8 namespace cc { | 8 namespace cc { |
| 9 | 9 |
| 10 MainThreadRenderingStats::MainThreadRenderingStats() | 10 MainThreadRenderingStats::MainThreadRenderingStats() |
| 11 : animation_frame_count(0), | 11 : frame_count(0), |
| 12 screen_frame_count(0), | 12 painted_pixel_count(0), |
| 13 commit_count(0), | 13 recorded_pixel_count(0) {} |
| 14 painted_pixel_count(0), | |
| 15 recorded_pixel_count(0), | |
| 16 image_gathering_count(0) {} | |
| 17 | |
| 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), | |
| 24 drawn_layer_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) {} | |
| 30 | |
| 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()); | |
| 78 } | |
| 79 | 14 |
| 80 void MainThreadRenderingStats::IssueTraceEvent() const { | 15 void MainThreadRenderingStats::IssueTraceEvent() const { |
| 81 TRACE_EVENT_INSTANT1("benchmark", | 16 TRACE_EVENT_INSTANT1("benchmark", |
| 82 "MainThreadRenderingStats::IssueTraceEvent", | 17 "MainThreadRenderingStats::IssueTraceEvent", |
| 83 TRACE_EVENT_SCOPE_THREAD, | 18 TRACE_EVENT_SCOPE_THREAD, |
| 84 "data", AsTraceableData()); | 19 "data", AsTraceableData()); |
| 85 } | 20 } |
| 86 | 21 |
| 87 scoped_ptr<base::debug::ConvertableToTraceFormat> | 22 scoped_ptr<base::debug::ConvertableToTraceFormat> |
| 88 MainThreadRenderingStats::AsTraceableData() const { | 23 MainThreadRenderingStats::AsTraceableData() const { |
| 89 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); | 24 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); |
| 90 record_data->SetInteger("animation_frame_count", | 25 record_data->SetInteger("frame_count", frame_count); |
| 91 animation_frame_count); | 26 record_data->SetDouble("paint_time", paint_time.InSecondsF()); |
| 92 record_data->SetInteger("screen_frame_count", | 27 record_data->SetInteger("painted_pixel_count", painted_pixel_count); |
| 93 screen_frame_count); | 28 record_data->SetDouble("record_time", record_time.InSecondsF()); |
| 94 record_data->SetDouble("paint_time", | 29 record_data->SetInteger("recorded_pixel_count", recorded_pixel_count); |
| 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", | |
| 103 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()); | 30 return TracedValue::FromValue(record_data.release()); |
| 113 } | 31 } |
| 114 | 32 |
| 33 void MainThreadRenderingStats::Add(const MainThreadRenderingStats& other) { |
| 34 frame_count += other.frame_count; |
| 35 paint_time += other.paint_time; |
| 36 painted_pixel_count += other.painted_pixel_count; |
| 37 record_time += other.record_time; |
| 38 recorded_pixel_count += other.recorded_pixel_count; |
| 39 } |
| 40 |
| 41 ImplThreadRenderingStats::ImplThreadRenderingStats() |
| 42 : frame_count(0), |
| 43 rasterized_pixel_count(0) {} |
| 44 |
| 115 void ImplThreadRenderingStats::IssueTraceEvent() const { | 45 void ImplThreadRenderingStats::IssueTraceEvent() const { |
| 116 TRACE_EVENT_INSTANT1("benchmark", | 46 TRACE_EVENT_INSTANT1("benchmark", |
| 117 "ImplThreadRenderingStats::IssueTraceEvent", | 47 "ImplThreadRenderingStats::IssueTraceEvent", |
| 118 TRACE_EVENT_SCOPE_THREAD, | 48 TRACE_EVENT_SCOPE_THREAD, |
| 119 "data", AsTraceableData()); | 49 "data", AsTraceableData()); |
| 120 } | 50 } |
| 121 | 51 |
| 122 scoped_ptr<base::debug::ConvertableToTraceFormat> | 52 scoped_ptr<base::debug::ConvertableToTraceFormat> |
| 123 ImplThreadRenderingStats::AsTraceableData() const { | 53 ImplThreadRenderingStats::AsTraceableData() const { |
| 124 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); | 54 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); |
| 125 record_data->SetInteger("screen_frame_count", | 55 record_data->SetInteger("frame_count", frame_count); |
| 126 screen_frame_count); | 56 record_data->SetDouble("rasterize_time", rasterize_time.InSecondsF()); |
| 127 record_data->SetInteger("dropped_frame_count", | 57 record_data->SetInteger("rasterized_pixel_count", rasterized_pixel_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", | |
| 143 drawn_layer_count); | |
| 144 record_data->SetInteger("missing_tile_count", | |
| 145 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()); | 58 return TracedValue::FromValue(record_data.release()); |
| 159 } | 59 } |
| 160 | 60 |
| 161 | 61 void ImplThreadRenderingStats::Add(const ImplThreadRenderingStats& other) { |
| 162 void MainThreadRenderingStats::Add(const MainThreadRenderingStats& other) { | 62 frame_count += other.frame_count; |
| 163 animation_frame_count += other.animation_frame_count; | 63 rasterize_time += other.rasterize_time; |
| 164 screen_frame_count += other.screen_frame_count; | 64 rasterized_pixel_count += other.rasterized_pixel_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; | |
| 174 } | 65 } |
| 175 | 66 |
| 176 void ImplThreadRenderingStats::Add(const ImplThreadRenderingStats& other) { | 67 void RenderingStats::EnumerateFields(Enumerator* enumerator) const { |
| 177 screen_frame_count += other.screen_frame_count; | 68 enumerator->AddInt64("frameCount", |
| 178 dropped_frame_count += other.dropped_frame_count; | 69 main_stats.frame_count + impl_stats.frame_count); |
| 179 rasterize_time += other.rasterize_time; | 70 enumerator->AddDouble("paintTime", |
| 180 rasterize_time_for_now_bins_on_pending_tree += | 71 main_stats.paint_time.InSecondsF()); |
| 181 other.rasterize_time_for_now_bins_on_pending_tree; | 72 enumerator->AddInt64("paintedPixelCount", |
| 182 best_rasterize_time += other.best_rasterize_time; | 73 main_stats.painted_pixel_count); |
| 183 rasterized_pixel_count += other.rasterized_pixel_count; | 74 enumerator->AddDouble("recordTime", |
| 184 impl_thread_scroll_count += other.impl_thread_scroll_count; | 75 main_stats.record_time.InSecondsF()); |
| 185 main_thread_scroll_count += other.main_thread_scroll_count; | 76 enumerator->AddInt64("recordedPixelCount", |
| 186 drawn_layer_count += other.drawn_layer_count; | 77 main_stats.recorded_pixel_count); |
| 187 missing_tile_count += other.missing_tile_count; | 78 enumerator->AddDouble("rasterizeTime", |
| 188 deferred_image_decode_count += other.deferred_image_decode_count; | 79 impl_stats.rasterize_time.InSecondsF()); |
| 189 deferred_image_cache_hit_count += other.deferred_image_cache_hit_count; | 80 enumerator->AddInt64("rasterizedPixelCount", |
| 190 deferred_image_decode_time += other.deferred_image_decode_time; | 81 impl_stats.rasterized_pixel_count); |
| 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; | |
| 194 } | 82 } |
| 195 | 83 |
| 196 void RenderingStats::Add(const RenderingStats& other) { | 84 void RenderingStats::Add(const RenderingStats& other) { |
| 197 main_stats.Add(other.main_stats); | 85 main_stats.Add(other.main_stats); |
| 198 impl_stats.Add(other.impl_stats); | 86 impl_stats.Add(other.impl_stats); |
| 199 } | 87 } |
| 200 | 88 |
| 201 } // namespace cc | 89 } // namespace cc |
| OLD | NEW |