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

Side by Side Diff: cc/debug/rasterize_and_record_benchmark.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 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/debug/rasterize_and_record_benchmark.h" 5 #include "cc/debug/rasterize_and_record_benchmark.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "cc/debug/lap_timer.h" 14 #include "cc/debug/lap_timer.h"
15 #include "cc/debug/rasterize_and_record_benchmark_impl.h" 15 #include "cc/debug/rasterize_and_record_benchmark_impl.h"
16 #include "cc/layers/layer.h" 16 #include "cc/layers/layer.h"
17 #include "cc/layers/picture_layer.h" 17 #include "cc/layers/picture_layer.h"
18 #include "cc/resources/picture_pile.h" 18 #include "cc/resources/picture_pile.h"
19 #include "cc/trees/layer_tree_host.h" 19 #include "cc/trees/layer_tree_host.h"
20 #include "cc/trees/layer_tree_host_common.h" 20 #include "cc/trees/layer_tree_host_common.h"
21 #include "third_party/skia/include/utils/SkPictureUtils.h"
21 #include "ui/gfx/geometry/rect.h" 22 #include "ui/gfx/geometry/rect.h"
22 23
23 namespace cc { 24 namespace cc {
24 25
25 namespace { 26 namespace {
26 27
27 const int kDefaultRecordRepeatCount = 100; 28 const int kDefaultRecordRepeatCount = 100;
28 29
29 const char* kModeSuffixes[Picture::RECORDING_MODE_COUNT] = { 30 const char* kModeSuffixes[Picture::RECORDING_MODE_COUNT] = {
30 "", 31 "",
(...skipping 26 matching lines...) Expand all
57 58
58 void RasterizeAndRecordBenchmark::DidUpdateLayers(LayerTreeHost* host) { 59 void RasterizeAndRecordBenchmark::DidUpdateLayers(LayerTreeHost* host) {
59 host_ = host; 60 host_ = host;
60 LayerTreeHostCommon::CallFunctionForSubtree( 61 LayerTreeHostCommon::CallFunctionForSubtree(
61 host->root_layer(), 62 host->root_layer(),
62 base::Bind(&RasterizeAndRecordBenchmark::Run, base::Unretained(this))); 63 base::Bind(&RasterizeAndRecordBenchmark::Run, base::Unretained(this)));
63 64
64 DCHECK(!results_.get()); 65 DCHECK(!results_.get());
65 results_ = make_scoped_ptr(new base::DictionaryValue); 66 results_ = make_scoped_ptr(new base::DictionaryValue);
66 results_->SetInteger("pixels_recorded", record_results_.pixels_recorded); 67 results_->SetInteger("pixels_recorded", record_results_.pixels_recorded);
68 results_->SetInteger("picture_memory_usage", record_results_.bytes_used);
67 69
68 for (int i = 0; i < Picture::RECORDING_MODE_COUNT; i++) { 70 for (int i = 0; i < Picture::RECORDING_MODE_COUNT; i++) {
69 std::string name = base::StringPrintf("record_time%s_ms", kModeSuffixes[i]); 71 std::string name = base::StringPrintf("record_time%s_ms", kModeSuffixes[i]);
70 results_->SetDouble(name, 72 results_->SetDouble(name,
71 record_results_.total_best_time[i].InMillisecondsF()); 73 record_results_.total_best_time[i].InMillisecondsF());
72 } 74 }
73 main_thread_benchmark_done_ = true; 75 main_thread_benchmark_done_ = true;
74 } 76 }
75 77
76 void RasterizeAndRecordBenchmark::RecordRasterResults( 78 void RasterizeAndRecordBenchmark::RecordRasterResults(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 gfx::Rect visible_content_rect = gfx::ScaleToEnclosingRect( 114 gfx::Rect visible_content_rect = gfx::ScaleToEnclosingRect(
113 layer->visible_content_rect(), 1.f / layer->contents_scale_x()); 115 layer->visible_content_rect(), 1.f / layer->contents_scale_x());
114 if (visible_content_rect.IsEmpty()) 116 if (visible_content_rect.IsEmpty())
115 return; 117 return;
116 118
117 for (int mode_index = 0; mode_index < Picture::RECORDING_MODE_COUNT; 119 for (int mode_index = 0; mode_index < Picture::RECORDING_MODE_COUNT;
118 mode_index++) { 120 mode_index++) {
119 Picture::RecordingMode mode = 121 Picture::RecordingMode mode =
120 static_cast<Picture::RecordingMode>(mode_index); 122 static_cast<Picture::RecordingMode>(mode_index);
121 base::TimeDelta min_time = base::TimeDelta::Max(); 123 base::TimeDelta min_time = base::TimeDelta::Max();
124 size_t memory_used = 0;
122 125
123 // Parameters for LapTimer. 126 // Parameters for LapTimer.
124 const int kTimeLimitMillis = 1; 127 const int kTimeLimitMillis = 1;
125 const int kWarmupRuns = 0; 128 const int kWarmupRuns = 0;
126 const int kTimeCheckInterval = 1; 129 const int kTimeCheckInterval = 1;
127 130
128 for (int i = 0; i < record_repeat_count_; ++i) { 131 for (int i = 0; i < record_repeat_count_; ++i) {
129 // Run for a minimum amount of time to avoid problems with timer 132 // Run for a minimum amount of time to avoid problems with timer
130 // quantization when the layer is very small. 133 // quantization when the layer is very small.
131 LapTimer timer(kWarmupRuns, 134 LapTimer timer(kWarmupRuns,
132 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), 135 base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
133 kTimeCheckInterval); 136 kTimeCheckInterval);
137 scoped_refptr<Picture> picture;
134 do { 138 do {
135 scoped_refptr<Picture> picture = Picture::Create( 139 picture = Picture::Create(visible_content_rect, painter, tile_grid_info,
136 visible_content_rect, painter, tile_grid_info, false, mode); 140 false, mode);
137 timer.NextLap(); 141 timer.NextLap();
138 } while (!timer.HasTimeLimitExpired()); 142 } while (!timer.HasTimeLimitExpired());
139 base::TimeDelta duration = 143 base::TimeDelta duration =
140 base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); 144 base::TimeDelta::FromMillisecondsD(timer.MsPerLap());
141 if (duration < min_time) 145 if (duration < min_time)
142 min_time = duration; 146 min_time = duration;
147 memory_used = picture->ApproximateMemoryUsage();
143 } 148 }
144 149
145 if (mode == Picture::RECORD_NORMALLY) { 150 if (mode == Picture::RECORD_NORMALLY) {
151 record_results_.bytes_used += memory_used;
146 record_results_.pixels_recorded += 152 record_results_.pixels_recorded +=
147 visible_content_rect.width() * visible_content_rect.height(); 153 visible_content_rect.width() * visible_content_rect.height();
148 } 154 }
149 record_results_.total_best_time[mode_index] += min_time; 155 record_results_.total_best_time[mode_index] += min_time;
150 } 156 }
151 } 157 }
152 158
153 RasterizeAndRecordBenchmark::RecordResults::RecordResults() 159 RasterizeAndRecordBenchmark::RecordResults::RecordResults()
154 : pixels_recorded(0) {} 160 : pixels_recorded(0), bytes_used(0) {
161 }
155 162
156 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {} 163 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {}
157 164
158 } // namespace cc 165 } // namespace cc
OLDNEW
« no previous file with comments | « cc/debug/rasterize_and_record_benchmark.h ('k') | cc/debug/rasterize_and_record_benchmark_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698