| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/benchmarks/rasterize_and_record_benchmark.h" | 5 #include "cc/benchmarks/rasterize_and_record_benchmark.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "cc/base/lap_timer.h" | 16 #include "cc/base/lap_timer.h" |
| 17 #include "cc/benchmarks/rasterize_and_record_benchmark_impl.h" | 17 #include "cc/benchmarks/rasterize_and_record_benchmark_impl.h" |
| 18 #include "cc/layers/content_layer_client.h" | 18 #include "cc/layers/content_layer_client.h" |
| 19 #include "cc/layers/layer.h" | 19 #include "cc/layers/layer.h" |
| 20 #include "cc/layers/picture_layer.h" | 20 #include "cc/layers/picture_layer.h" |
| 21 #include "cc/layers/recording_source.h" | 21 #include "cc/layers/recording_source.h" |
| 22 #include "cc/paint/display_item_list.h" | 22 #include "cc/paint/display_item_list.h" |
| 23 #include "cc/trees/layer_tree_host.h" | 23 #include "cc/trees/layer_tree_host.h" |
| 24 #include "cc/trees/layer_tree_host_common.h" | 24 #include "cc/trees/layer_tree_host_common.h" |
| 25 #include "skia/ext/analysis_canvas.h" | 25 #include "skia/ext/analysis_canvas.h" |
| 26 #include "ui/gfx/geometry/rect.h" | 26 #include "ui/gfx/geometry/rect.h" |
| 27 | 27 |
| 28 namespace blink { |
| 29 int* paintCounts(); |
| 30 int* rareDataReasonCounts(); |
| 31 int* frameCounts(); |
| 32 } |
| 33 |
| 28 namespace cc { | 34 namespace cc { |
| 29 | 35 |
| 30 namespace { | 36 namespace { |
| 31 | 37 |
| 32 const int kDefaultRecordRepeatCount = 100; | 38 const int kDefaultRecordRepeatCount = 100; |
| 33 | 39 |
| 34 // Parameters for LapTimer. | 40 // Parameters for LapTimer. |
| 35 const int kTimeLimitMillis = 1; | 41 const int kTimeLimitMillis = 1; |
| 36 const int kWarmupRuns = 0; | 42 const int kWarmupRuns = 0; |
| 37 const int kTimeCheckInterval = 1; | 43 const int kTimeCheckInterval = 1; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 return; | 88 return; |
| 83 | 89 |
| 84 if (settings->HasKey("record_repeat_count")) | 90 if (settings->HasKey("record_repeat_count")) |
| 85 settings->GetInteger("record_repeat_count", &record_repeat_count_); | 91 settings->GetInteger("record_repeat_count", &record_repeat_count_); |
| 86 } | 92 } |
| 87 | 93 |
| 88 RasterizeAndRecordBenchmark::~RasterizeAndRecordBenchmark() { | 94 RasterizeAndRecordBenchmark::~RasterizeAndRecordBenchmark() { |
| 89 weak_ptr_factory_.InvalidateWeakPtrs(); | 95 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 90 } | 96 } |
| 91 | 97 |
| 98 static const int kMaxReason = 58; |
| 99 |
| 100 static const char* reasonNames[kMaxReason] = { |
| 101 "lo_all", |
| 102 "lo_inFlowSelfPaintingLayer", |
| 103 "lo_inFlowSelfPaintingLayerDiffPC", |
| 104 "lo_previousLocation", |
| 105 "lo_floatLayerBug1", |
| 106 "lo_floatLayerBug2", |
| 107 "lo_svgForeignBug", |
| 108 "li_all", |
| 109 "li_createsLineBoxes", |
| 110 "lt_all", |
| 111 "lt_canUseParentVisualRect", |
| 112 "lt_zeroOrOneLineBox", |
| 113 "lt_zeroOrOneLineBoxCanUse", |
| 114 "lb_all", |
| 115 "lb_rareData", |
| 116 "lb_inlineBoxWrapper", |
| 117 "lb_spannerPlaceholder", |
| 118 "lb_overrideSize", |
| 119 "lb_pageOffset", |
| 120 "lb_paginationStrut", |
| 121 "lb_previousSize", |
| 122 "lb_previousLayoutOverflow", |
| 123 "lb_previousContentBox", |
| 124 "lb_previousContentBoxSizeIfDiff", |
| 125 "lb_positionedContainer", |
| 126 "lb_positionedDiffPC", |
| 127 "lb_percentHeightContainer", |
| 128 "lb_contentBoxDiff", |
| 129 "lb_layoutOverflowDiff", |
| 130 "lbl_all", |
| 131 "lbl_positionedDescendants", |
| 132 "lbl_percentHeightDescendants", |
| 133 "lbf_all", |
| 134 "lbf_rareData", |
| 135 "lbf_paginationStrutFromChild", |
| 136 "lbf_lineBreakToAvoidWidow", |
| 137 "lbf_discardMargin", |
| 138 "lbf_margin", |
| 139 "lbf_multiColumnFlowThread", |
| 140 "lts_all", |
| 141 "lts_composited", |
| 142 "lts_nonComposited", |
| 143 "lts_compositedWithContainerBackground", |
| 144 "ltr_all", |
| 145 "ltr_composited", |
| 146 "ltr_nonComposited", |
| 147 "ltr_compositedWithContainerBackground", |
| 148 "ltc_all", |
| 149 "ltc_invisibleCollapsedBorders", |
| 150 "ltc_collapsedBorders", |
| 151 "ltc_composited", |
| 152 "ltc_nonComposited", |
| 153 "ltc_compositedWithContainerBackground", |
| 154 "lo_object", |
| 155 "lo_box", |
| 156 "lo_text", |
| 157 "lo_inline", |
| 158 "lo_svg", |
| 159 }; |
| 160 |
| 161 static const char* paintNames[] = { |
| 162 "p_empty_background", "p_empty_float", "p_empty_foreground", |
| 163 "p_empty_outline", "p_empty_all", "p_all", |
| 164 "p_no_background", "p_no_float", "p_no_outline", |
| 165 }; |
| 166 |
| 167 static const char* frameNames[] = { |
| 168 "frame_all", |
| 169 "frame_remote", |
| 170 "frame_noOwnerLayoutObject", |
| 171 "frame_throttled", |
| 172 "frame_throttledNoOwnerLayoutObject", |
| 173 "frame_noLayoutView", |
| 174 "frame_noView", |
| 175 }; |
| 176 |
| 92 void RasterizeAndRecordBenchmark::DidUpdateLayers( | 177 void RasterizeAndRecordBenchmark::DidUpdateLayers( |
| 93 LayerTreeHost* layer_tree_host) { | 178 LayerTreeHost* layer_tree_host) { |
| 94 layer_tree_host_ = layer_tree_host; | 179 layer_tree_host_ = layer_tree_host; |
| 95 LayerTreeHostCommon::CallFunctionForEveryLayer( | 180 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 96 layer_tree_host_, | 181 layer_tree_host_, |
| 97 [this](Layer* layer) { layer->RunMicroBenchmark(this); }); | 182 [this](Layer* layer) { layer->RunMicroBenchmark(this); }); |
| 98 | 183 |
| 99 DCHECK(!results_.get()); | 184 DCHECK(!results_.get()); |
| 100 results_ = base::WrapUnique(new base::DictionaryValue); | 185 results_ = base::WrapUnique(new base::DictionaryValue); |
| 101 results_->SetInteger("pixels_recorded", record_results_.pixels_recorded); | 186 results_->SetInteger("pixels_recorded", record_results_.pixels_recorded); |
| 102 results_->SetInteger("picture_memory_usage", | 187 results_->SetInteger("picture_memory_usage", |
| 103 static_cast<int>(record_results_.bytes_used)); | 188 static_cast<int>(record_results_.bytes_used)); |
| 189 int* reason_counts = blink::rareDataReasonCounts(); |
| 190 for (int i = 0; i < kMaxReason; ++i) { |
| 191 results_->SetInteger(reasonNames[i], reason_counts[i]); |
| 192 reason_counts[i] = 0; |
| 193 } |
| 194 |
| 195 int* paint_counts = blink::paintCounts(); |
| 196 for (int i = 0; i < 9; ++i) { |
| 197 results_->SetInteger(paintNames[i], paint_counts[i]); |
| 198 paint_counts[i] = 0; |
| 199 } |
| 200 |
| 201 int* frame_counts = blink::frameCounts(); |
| 202 for (int i = 0; i < 7; ++i) { |
| 203 results_->SetInteger(frameNames[i], frame_counts[i]); |
| 204 } |
| 104 | 205 |
| 105 for (int i = 0; i < RecordingSource::RECORDING_MODE_COUNT; i++) { | 206 for (int i = 0; i < RecordingSource::RECORDING_MODE_COUNT; i++) { |
| 106 std::string name = base::StringPrintf("record_time%s_ms", kModeSuffixes[i]); | 207 std::string name = base::StringPrintf("record_time%s_ms", kModeSuffixes[i]); |
| 107 results_->SetDouble(name, | 208 results_->SetDouble(name, |
| 108 record_results_.total_best_time[i].InMillisecondsF()); | 209 record_results_.total_best_time[i].InMillisecondsF()); |
| 109 } | 210 } |
| 110 main_thread_benchmark_done_ = true; | 211 main_thread_benchmark_done_ = true; |
| 111 } | 212 } |
| 112 | 213 |
| 113 void RasterizeAndRecordBenchmark::RecordRasterResults( | 214 void RasterizeAndRecordBenchmark::RecordRasterResults( |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 record_results_.total_best_time[mode_index] += min_time; | 289 record_results_.total_best_time[mode_index] += min_time; |
| 189 } | 290 } |
| 190 } | 291 } |
| 191 | 292 |
| 192 RasterizeAndRecordBenchmark::RecordResults::RecordResults() | 293 RasterizeAndRecordBenchmark::RecordResults::RecordResults() |
| 193 : pixels_recorded(0), bytes_used(0) {} | 294 : pixels_recorded(0), bytes_used(0) {} |
| 194 | 295 |
| 195 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {} | 296 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {} |
| 196 | 297 |
| 197 } // namespace cc | 298 } // namespace cc |
| OLD | NEW |