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

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

Issue 10537036: Added rendering benchmark javascript hook (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Patch Created 8 years, 5 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/renderer/all_rendering_benchmarks.h"
6
7 #include "base/bind.h"
8 #include "base/callback.h"
9 #include "base/time.h"
10 #include "content/renderer/rendering_benchmark.h"
11 #include "content/renderer/rendering_benchmark_results.h"
12 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "third_party/skia/include/core/SkDevice.h"
14 #include "third_party/skia/include/utils/SkNullCanvas.h"
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebCanvas.h"
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewBenchmarkSuppo rt.h"
18
19 using base::TimeDelta;
20 using base::TimeTicks;
21 using WebKit::WebSize;
22 using WebKit::WebCanvas;
23 using WebKit::WebViewBenchmarkSupport;
24
25 namespace {
26 typedef base::Callback<WebCanvas*(const WebSize&)> CanvasCallback;
27
28 class CustomPaintBenchmark
29 : public content::RenderingBenchmark,
30 public WebViewBenchmarkSupport::PaintClient {
31 public:
32 CustomPaintBenchmark(const std::string& name,
33 WebViewBenchmarkSupport::PaintMode paint_mode)
34 : content::RenderingBenchmark(name),
35 paint_mode_(paint_mode) { }
36
37 virtual void willPaint(const WebCanvas& /* canvas */) {
38 beforeTime = TimeTicks::Now();
39 }
40
41 virtual void didPaint(const WebCanvas& /* canvas */) {
42 paintTimeTotal += (TimeTicks::Now() - beforeTime);
43 }
44
45 virtual void Run(content::RenderingBenchmarkResults* results,
46 WebViewBenchmarkSupport* support) {
47 paintTimeTotal = TimeDelta();
48 support->paint(this, paint_mode_);
49 results->addResult(name(), "paintTime", "s", paintTimeTotal.InSecondsF());
50 }
51
52 private:
53 TimeTicks beforeTime;
nduca 2012/07/20 20:30:09 beforeTime_ here and elsewhere, members get _
dmurph 2012/07/20 20:52:33 Done.
54 TimeDelta paintTimeTotal;
55 const WebViewBenchmarkSupport::PaintMode paint_mode_;
56 };
57
58 class BitmapCanvasPaintBenchmark : public CustomPaintBenchmark {
59 public:
60 BitmapCanvasPaintBenchmark(const std::string& name,
61 WebViewBenchmarkSupport::PaintMode paint_mode)
62 : CustomPaintBenchmark(name, paint_mode) { }
63
64 virtual WebCanvas* createCanvas(const WebSize& size) OVERRIDE {
65 SkDevice* device = new SkDevice(SkBitmap::kARGB_8888_Config,
66 size.width,
67 size.height,
68 false);
69 WebCanvas* canvas = new WebCanvas(device);
70 device->unref();
71 return canvas;
72 }
73 };
74
75 class NullCanvasPaintBenchmark : public CustomPaintBenchmark {
76 public:
77 NullCanvasPaintBenchmark(const std::string& name,
78 WebViewBenchmarkSupport::PaintMode paint_mode)
79 : CustomPaintBenchmark(name, paint_mode) { }
80
81 virtual WebCanvas* createCanvas(const WebSize& size) OVERRIDE {
82 return SkCreateNullCanvas();
83 }
84 };
85 } // anonymous namespace
86
87 namespace content {
88
89 std::vector<RenderingBenchmark*> AllRenderingBenchmarks() {
90 std::vector<RenderingBenchmark*> benchmarks;
91 benchmarks.push_back(new BitmapCanvasPaintBenchmark(
92 "PaintEverythingToBitmap",
93 WebViewBenchmarkSupport::PaintModeEverything));
94 benchmarks.push_back(new NullCanvasPaintBenchmark(
95 "PaintEverythingToNullCanvas",
96 WebViewBenchmarkSupport::PaintModeEverything));
97 return benchmarks;
98 }
99
100 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698