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

Side by Side Diff: content/renderer/all_rendering_benchmarks.cc

Issue 10827421: Removed benchmark results object from rendering benchmarks, now one result per benchmark (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/gpu/gpu_benchmarking_extension.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "content/renderer/all_rendering_benchmarks.h" 5 #include "content/renderer/all_rendering_benchmarks.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/time.h" 15 #include "base/time.h"
16 #include "content/renderer/rendering_benchmark.h" 16 #include "content/renderer/rendering_benchmark.h"
17 #include "content/renderer/rendering_benchmark_results.h"
18 #include "skia/ext/platform_canvas.h" 17 #include "skia/ext/platform_canvas.h"
19 #include "third_party/skia/include/core/SkPicture.h" 18 #include "third_party/skia/include/core/SkPicture.h"
20 #include "third_party/skia/include/utils/SkNullCanvas.h" 19 #include "third_party/skia/include/utils/SkNullCanvas.h"
21 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h"
22 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" 21 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewBenchmarkSuppo rt.h" 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewBenchmarkSuppo rt.h"
24 23
25 using base::TimeDelta; 24 using base::TimeDelta;
26 using base::TimeTicks; 25 using base::TimeTicks;
27 using WebKit::WebSize; 26 using WebKit::WebSize;
(...skipping 19 matching lines...) Expand all
47 WebCanvas* canvas = createCanvas(size); 46 WebCanvas* canvas = createCanvas(size);
48 before_time_ = TimeTicks::HighResNow(); 47 before_time_ = TimeTicks::HighResNow();
49 return canvas; 48 return canvas;
50 } 49 }
51 50
52 virtual void didPaint(WebCanvas* canvas) OVERRIDE { 51 virtual void didPaint(WebCanvas* canvas) OVERRIDE {
53 paint_time_total_ += (TimeTicks::HighResNow() - before_time_); 52 paint_time_total_ += (TimeTicks::HighResNow() - before_time_);
54 delete canvas; 53 delete canvas;
55 } 54 }
56 55
57 virtual void Run(content::RenderingBenchmarkResults* results, 56 virtual double Run(WebViewBenchmarkSupport* support) OVERRIDE {
58 WebViewBenchmarkSupport* support) OVERRIDE {
59 paint_time_total_ = TimeDelta(); 57 paint_time_total_ = TimeDelta();
60 support->paint(this, paint_mode_); 58 support->paint(this, paint_mode_);
61 results->AddResult(name(), 59 return paint_time_total_.InMillisecondsF();
piman 2012/08/20 17:58:56 did you intend to switch from seconds to milliseco
dmurph 2012/08/20 19:30:08 Yeah, that's intended.
62 "paintTime",
63 "s",
64 paint_time_total_.InSecondsF());
65 } 60 }
66 61
67 private: 62 private:
68 virtual WebCanvas* createCanvas(const WebSize& size) = 0; 63 virtual WebCanvas* createCanvas(const WebSize& size) = 0;
69 64
70 TimeTicks before_time_; 65 TimeTicks before_time_;
71 TimeDelta paint_time_total_; 66 TimeDelta paint_time_total_;
72 const WebViewBenchmarkSupport::PaintMode paint_mode_; 67 const WebViewBenchmarkSupport::PaintMode paint_mode_;
73 }; 68 };
74 69
75 class BitmapCanvasPaintBenchmark : public CustomPaintBenchmark { 70 class BitmapCanvasPaintBenchmark : public CustomPaintBenchmark {
76 public: 71 public:
77 BitmapCanvasPaintBenchmark(const std::string& name, 72 BitmapCanvasPaintBenchmark(const std::string& name,
78 WebViewBenchmarkSupport::PaintMode paint_mode) 73 WebViewBenchmarkSupport::PaintMode paint_mode)
79 : CustomPaintBenchmark(name, paint_mode) { } 74 : CustomPaintBenchmark(name, paint_mode) { }
80 75
81 private: 76 private:
82 virtual WebCanvas* createCanvas(const WebSize& size) OVERRIDE { 77 virtual WebCanvas* createCanvas(const WebSize& size) OVERRIDE {
83 return skia::CreateBitmapCanvas(size.width, size.height, false); 78 return skia::CreateBitmapCanvas(size.width, size.height, false);
84 } 79 }
85 }; 80 };
86 81
82 class CanvasCountBenchmark
83 : public content::RenderingBenchmark,
84 public WebViewBenchmarkSupport::PaintClient {
85 public:
86 CanvasCountBenchmark(const std::string& name,
87 WebViewBenchmarkSupport::PaintMode paint_mode)
88 : content::RenderingBenchmark(name),
89 canvas_count_(0),
90 paint_mode_(paint_mode) { }
91
92 virtual WebCanvas* willPaint(const WebSize& size) OVERRIDE {
93 ++canvas_count_;
94 return SkCreateNullCanvas();
95 }
96
97 virtual void didPaint(WebCanvas* canvas) OVERRIDE {
98 delete canvas;
99 }
100
101 virtual double Run(WebViewBenchmarkSupport* support) OVERRIDE {
102 canvas_count_ = 0;
103 support->paint(this, paint_mode_);
104 return canvas_count_;
105 }
106 private:
107 int canvas_count_;
108 const WebViewBenchmarkSupport::PaintMode paint_mode_;
109 };
110
87 class NullCanvasPaintBenchmark : public CustomPaintBenchmark { 111 class NullCanvasPaintBenchmark : public CustomPaintBenchmark {
88 public: 112 public:
89 NullCanvasPaintBenchmark(const std::string& name, 113 NullCanvasPaintBenchmark(const std::string& name,
90 WebViewBenchmarkSupport::PaintMode paint_mode) 114 WebViewBenchmarkSupport::PaintMode paint_mode)
91 : CustomPaintBenchmark(name, paint_mode), 115 : CustomPaintBenchmark(name, paint_mode) { }
92 canvas_count_(0) { }
93
94 virtual void Run(content::RenderingBenchmarkResults* results,
95 WebViewBenchmarkSupport* support) OVERRIDE {
96 canvas_count_ = 0;
97 CustomPaintBenchmark::Run(results, support);
98 results->AddResult(name(),
99 "canvasCount",
100 "i",
101 canvas_count_);
102 }
103 116
104 private: 117 private:
105 virtual WebCanvas* createCanvas(const WebSize& size) OVERRIDE { 118 virtual WebCanvas* createCanvas(const WebSize& size) OVERRIDE {
106 ++canvas_count_;
107 return SkCreateNullCanvas(); 119 return SkCreateNullCanvas();
108 } 120 }
109
110 int canvas_count_;
111 }; 121 };
112 122
113 class SkPicturePaintBenchmark : public CustomPaintBenchmark { 123 class SkPicturePaintBenchmark : public CustomPaintBenchmark {
114 public: 124 public:
115 SkPicturePaintBenchmark(const std::string& name, 125 SkPicturePaintBenchmark(const std::string& name,
116 WebViewBenchmarkSupport::PaintMode paint_mode) 126 WebViewBenchmarkSupport::PaintMode paint_mode)
117 : CustomPaintBenchmark(name, paint_mode) { } 127 : CustomPaintBenchmark(name, paint_mode) { }
118 128
119 virtual void didPaint(WebCanvas* canvas) OVERRIDE { 129 virtual void didPaint(WebCanvas* canvas) OVERRIDE {
120 DCHECK(picture_.getRecordingCanvas() == canvas); 130 DCHECK(picture_.getRecordingCanvas() == canvas);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 WebRect tile = *it; 166 WebRect tile = *it;
157 scoped_ptr<WebCanvas> canvas( 167 scoped_ptr<WebCanvas> canvas(
158 skia::CreateBitmapCanvas(tile.width, tile.height, false)); 168 skia::CreateBitmapCanvas(tile.width, tile.height, false));
159 TimeTicks before_time = TimeTicks::HighResNow(); 169 TimeTicks before_time = TimeTicks::HighResNow();
160 canvas->translate(-tile.x, -tile.y); 170 canvas->translate(-tile.x, -tile.y);
161 picture_.draw(canvas.get()); 171 picture_.draw(canvas.get());
162 paint_time_total_ += (TimeTicks::HighResNow() - before_time); 172 paint_time_total_ += (TimeTicks::HighResNow() - before_time);
163 } 173 }
164 } 174 }
165 175
166 virtual void Run(content::RenderingBenchmarkResults* results, 176 virtual double Run(WebViewBenchmarkSupport* support) {
167 WebViewBenchmarkSupport* support) {
168 paint_time_total_ = TimeDelta(); 177 paint_time_total_ = TimeDelta();
169 support->paint(this, paint_mode_); 178 support->paint(this, paint_mode_);
170 results->AddResult(name(), 179 return paint_time_total_.InMillisecondsF();
171 "repaintTime",
172 "s",
173 paint_time_total_.InSecondsF());
174 } 180 }
175 181
176 private: 182 private:
177 virtual vector<WebRect> GetRepaintTiles(const WebSize& layer_size) const = 0; 183 virtual vector<WebRect> GetRepaintTiles(const WebSize& layer_size) const = 0;
178 184
179 TimeDelta paint_time_total_; 185 TimeDelta paint_time_total_;
180 SkPicture picture_; 186 SkPicture picture_;
181 const WebViewBenchmarkSupport::PaintMode paint_mode_; 187 const WebViewBenchmarkSupport::PaintMode paint_mode_;
182 }; 188 };
183 189
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 int tile_height_; 238 int tile_height_;
233 }; 239 };
234 240
235 } // anonymous namespace 241 } // anonymous namespace
236 242
237 namespace content { 243 namespace content {
238 244
239 ScopedVector<RenderingBenchmark> AllRenderingBenchmarks() { 245 ScopedVector<RenderingBenchmark> AllRenderingBenchmarks() {
240 ScopedVector<RenderingBenchmark> benchmarks; 246 ScopedVector<RenderingBenchmark> benchmarks;
241 benchmarks.push_back(new BitmapCanvasPaintBenchmark( 247 benchmarks.push_back(new BitmapCanvasPaintBenchmark(
242 "PaintEverythingToBitmap", 248 "PaintEverythingToBitmapMs",
243 WebViewBenchmarkSupport::PaintModeEverything)); 249 WebViewBenchmarkSupport::PaintModeEverything));
244 benchmarks.push_back(new NullCanvasPaintBenchmark( 250 benchmarks.push_back(new NullCanvasPaintBenchmark(
245 "PaintEverythingToNullCanvas", 251 "PaintEverythingToNullCanvasMs",
252 WebViewBenchmarkSupport::PaintModeEverything));
253 benchmarks.push_back(new CanvasCountBenchmark(
254 "LayerCount",
246 WebViewBenchmarkSupport::PaintModeEverything)); 255 WebViewBenchmarkSupport::PaintModeEverything));
247 benchmarks.push_back(new SkPicturePaintBenchmark( 256 benchmarks.push_back(new SkPicturePaintBenchmark(
248 "PaintEverythingToSkPicture", 257 "PaintEverythingToSkPictureMs",
249 WebViewBenchmarkSupport::PaintModeEverything)); 258 WebViewBenchmarkSupport::PaintModeEverything));
250 benchmarks.push_back(new SquareTiledReplayBenchmark( 259 benchmarks.push_back(new SquareTiledReplayBenchmark(
251 "RepaintEverythingTo256x256Bitmap", 260 "RepaintEverythingTo256x256BitmapMs",
252 WebViewBenchmarkSupport::PaintModeEverything, 261 WebViewBenchmarkSupport::PaintModeEverything,
253 256)); 262 256));
254 benchmarks.push_back(new SquareTiledReplayBenchmark( 263 benchmarks.push_back(new SquareTiledReplayBenchmark(
255 "RepaintEverythingTo128x128Bitmap", 264 "RepaintEverythingTo128x128BitmapMs",
256 WebViewBenchmarkSupport::PaintModeEverything, 265 WebViewBenchmarkSupport::PaintModeEverything,
257 128)); 266 128));
258 benchmarks.push_back(new SquareTiledReplayBenchmark( 267 benchmarks.push_back(new SquareTiledReplayBenchmark(
259 "RepaintEverythingTo512x512Bitmap", 268 "RepaintEverythingTo512x512BitmapMs",
260 WebViewBenchmarkSupport::PaintModeEverything, 269 WebViewBenchmarkSupport::PaintModeEverything,
261 512)); 270 512));
262 benchmarks.push_back(new LayerWidthTiledReplayBenchmark( 271 benchmarks.push_back(new LayerWidthTiledReplayBenchmark(
263 "RepaintEverythingToLayerWidthx256Bitmap", 272 "RepaintEverythingToLayerWidthx256BitmapMs",
264 WebViewBenchmarkSupport::PaintModeEverything, 273 WebViewBenchmarkSupport::PaintModeEverything,
265 256)); 274 256));
266 benchmarks.push_back(new LayerWidthTiledReplayBenchmark( 275 benchmarks.push_back(new LayerWidthTiledReplayBenchmark(
267 "RepaintEverythingToLayerWidthx128Bitmap", 276 "RepaintEverythingToLayerWidthx128BitmapMs",
268 WebViewBenchmarkSupport::PaintModeEverything, 277 WebViewBenchmarkSupport::PaintModeEverything,
269 128)); 278 128));
270 benchmarks.push_back(new LayerWidthTiledReplayBenchmark( 279 benchmarks.push_back(new LayerWidthTiledReplayBenchmark(
271 "RepaintEverythingToLayerWidthx64Bitmap", 280 "RepaintEverythingToLayerWidthx64BitmapMs",
272 WebViewBenchmarkSupport::PaintModeEverything, 281 WebViewBenchmarkSupport::PaintModeEverything,
273 64)); 282 64));
274 benchmarks.push_back(new LayerWidthTiledReplayBenchmark( 283 benchmarks.push_back(new LayerWidthTiledReplayBenchmark(
275 "RepaintEverythingToLayerWidthx512Bitmap", 284 "RepaintEverythingToLayerWidthx512BitmapMs",
276 WebViewBenchmarkSupport::PaintModeEverything, 285 WebViewBenchmarkSupport::PaintModeEverything,
277 512)); 286 512));
278 return benchmarks.Pass(); 287 return benchmarks.Pass();
279 } 288 }
280 289
281 } // namespace content 290 } // namespace content
OLDNEW
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/gpu/gpu_benchmarking_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698