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

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

Issue 279183002: Use LapTimer in rasterize_and_record micro benchmark. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add CC_EXPORT to LapTimer class. Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « cc/debug/lap_timer.cc ('k') | cc/debug/rasterize_and_record_benchmark_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/rasterize_and_record_benchmark_impl.h" 15 #include "cc/debug/rasterize_and_record_benchmark_impl.h"
15 #include "cc/layers/layer.h" 16 #include "cc/layers/layer.h"
16 #include "cc/layers/picture_layer.h" 17 #include "cc/layers/picture_layer.h"
17 #include "cc/trees/layer_tree_host.h" 18 #include "cc/trees/layer_tree_host.h"
18 #include "cc/trees/layer_tree_host_common.h" 19 #include "cc/trees/layer_tree_host_common.h"
19 #include "ui/gfx/rect.h" 20 #include "ui/gfx/rect.h"
20 21
21 namespace cc { 22 namespace cc {
22 23
23 namespace { 24 namespace {
24 25
25 const int kDefaultRecordRepeatCount = 100; 26 const int kDefaultRecordRepeatCount = 100;
26 27
27 const char* kModeSuffixes[Picture::RECORDING_MODE_COUNT] = { 28 const char* kModeSuffixes[Picture::RECORDING_MODE_COUNT] = {
28 "", "_sk_null_canvas", "_painting_disabled", "_skrecord"}; 29 "", "_sk_null_canvas", "_painting_disabled", "_skrecord"};
29 30
30 base::TimeTicks Now() {
31 return base::TimeTicks::IsThreadNowSupported()
32 ? base::TimeTicks::ThreadNow()
33 : base::TimeTicks::HighResNow();
34 }
35
36 } // namespace 31 } // namespace
37 32
38 RasterizeAndRecordBenchmark::RasterizeAndRecordBenchmark( 33 RasterizeAndRecordBenchmark::RasterizeAndRecordBenchmark(
39 scoped_ptr<base::Value> value, 34 scoped_ptr<base::Value> value,
40 const MicroBenchmark::DoneCallback& callback) 35 const MicroBenchmark::DoneCallback& callback)
41 : MicroBenchmark(callback), 36 : MicroBenchmark(callback),
42 record_repeat_count_(kDefaultRecordRepeatCount), 37 record_repeat_count_(kDefaultRecordRepeatCount),
43 settings_(value.Pass()), 38 settings_(value.Pass()),
44 main_thread_benchmark_done_(false), 39 main_thread_benchmark_done_(false),
45 host_(NULL), 40 host_(NULL),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 gfx::Rect visible_content_rect = gfx::ScaleToEnclosingRect( 109 gfx::Rect visible_content_rect = gfx::ScaleToEnclosingRect(
115 layer->visible_content_rect(), 1.f / layer->contents_scale_x()); 110 layer->visible_content_rect(), 1.f / layer->contents_scale_x());
116 if (visible_content_rect.IsEmpty()) 111 if (visible_content_rect.IsEmpty())
117 return; 112 return;
118 113
119 for (int mode_index = 0; mode_index < Picture::RECORDING_MODE_COUNT; 114 for (int mode_index = 0; mode_index < Picture::RECORDING_MODE_COUNT;
120 mode_index++) { 115 mode_index++) {
121 Picture::RecordingMode mode = 116 Picture::RecordingMode mode =
122 static_cast<Picture::RecordingMode>(mode_index); 117 static_cast<Picture::RecordingMode>(mode_index);
123 base::TimeDelta min_time = base::TimeDelta::Max(); 118 base::TimeDelta min_time = base::TimeDelta::Max();
119
120 // Parameters for LapTimer.
121 const int kTimeLimitMillis = 1;
122 const int kWarmupRuns = 0;
123 const int kTimeCheckInterval = 1;
124
124 for (int i = 0; i < record_repeat_count_; ++i) { 125 for (int i = 0; i < record_repeat_count_; ++i) {
125 base::TimeTicks start = Now(); 126 // Run for a minimum amount of time to avoid problems with timer
126 scoped_refptr<Picture> picture = Picture::Create( 127 // quantization when the layer is very small.
127 visible_content_rect, painter, tile_grid_info, false, 0, mode); 128 LapTimer timer(kWarmupRuns,
128 base::TimeTicks end = Now(); 129 base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
129 base::TimeDelta duration = end - start; 130 kTimeCheckInterval);
131 do {
132 scoped_refptr<Picture> picture = Picture::Create(
133 visible_content_rect, painter, tile_grid_info, false, 0, mode);
134 timer.NextLap();
135 } while (!timer.HasTimeLimitExpired());
136 base::TimeDelta duration =
137 base::TimeDelta::FromMillisecondsD(timer.MsPerLap());
130 if (duration < min_time) 138 if (duration < min_time)
131 min_time = duration; 139 min_time = duration;
132 } 140 }
133 141
134 if (mode == Picture::RECORD_NORMALLY) { 142 if (mode == Picture::RECORD_NORMALLY) {
135 record_results_.pixels_recorded += 143 record_results_.pixels_recorded +=
136 visible_content_rect.width() * visible_content_rect.height(); 144 visible_content_rect.width() * visible_content_rect.height();
137 } 145 }
138 record_results_.total_best_time[mode_index] += min_time; 146 record_results_.total_best_time[mode_index] += min_time;
139 } 147 }
140 } 148 }
141 149
142 RasterizeAndRecordBenchmark::RecordResults::RecordResults() 150 RasterizeAndRecordBenchmark::RecordResults::RecordResults()
143 : pixels_recorded(0) {} 151 : pixels_recorded(0) {}
144 152
145 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {} 153 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {}
146 154
147 } // namespace cc 155 } // namespace cc
OLDNEW
« no previous file with comments | « cc/debug/lap_timer.cc ('k') | cc/debug/rasterize_and_record_benchmark_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698