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

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: Refactorings for WebKit changes 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
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 <string>
8
9 #include "base/bind.h"
10 #include "base/callback.h"
11 #include "base/compiler_specific.h"
12 #include "base/time.h"
13 #include "content/renderer/rendering_benchmark.h"
14 #include "content/renderer/rendering_benchmark_results.h"
15 #include "third_party/skia/include/core/SkBitmap.h"
16 #include "third_party/skia/include/core/SkDevice.h"
17 #include "third_party/skia/include/utils/SkNullCanvas.h"
18 #include "third_party/WebKit/Source/Platform/chromium/public/WebCanvas.h"
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewBenchmarkSuppo rt.h"
21
22 using base::TimeDelta;
23 using base::TimeTicks;
24 using WebKit::WebSize;
25 using WebKit::WebCanvas;
26 using WebKit::WebViewBenchmarkSupport;
27
28 namespace {
29
30 class CustomPaintBenchmark
31 : public content::RenderingBenchmark,
32 public WebViewBenchmarkSupport::PaintClient {
33 public:
34 CustomPaintBenchmark(const std::string& name,
35 WebViewBenchmarkSupport::PaintMode paint_mode)
36 : content::RenderingBenchmark(name),
37 paint_mode_(paint_mode) { }
38
39 virtual WebCanvas* willPaint(const WebSize& size) OVERRIDE {
40 WebCanvas* canvas = createCanvas(size);
41 before_time_ = TimeTicks::Now();
42 return canvas;
43 }
44
45 virtual void didPaint(WebCanvas* canvas) OVERRIDE {
46 paint_time_total_ += (TimeTicks::Now() - before_time_);
47 delete canvas;
48 }
49
50 virtual void Run(content::RenderingBenchmarkResults* results,
51 WebViewBenchmarkSupport* support) {
52 paint_time_total_ = TimeDelta();
53 support->paint(this, paint_mode_);
54 results->AddResult(name(),
55 "paintTime",
56 "s",
57 paint_time_total_.InSecondsF());
58 }
59
60 private:
61 virtual WebCanvas* createCanvas(const WebSize& size) = 0;
62
63 TimeTicks before_time_;
64 TimeDelta paint_time_total_;
65 const WebViewBenchmarkSupport::PaintMode paint_mode_;
66 };
67
68 class BitmapCanvasPaintBenchmark : public CustomPaintBenchmark {
69 public:
70 BitmapCanvasPaintBenchmark(const std::string& name,
71 WebViewBenchmarkSupport::PaintMode paint_mode)
72 : CustomPaintBenchmark(name, paint_mode) { }
73
74 private:
75 virtual WebCanvas* createCanvas(const WebSize& size) OVERRIDE {
76 SkDevice* device = new SkDevice(SkBitmap::kARGB_8888_Config,
77 size.width,
78 size.height,
79 false);
80 WebCanvas* canvas = new WebCanvas(device);
81 device->unref();
82 return canvas;
83 }
84 };
85
86 class NullCanvasPaintBenchmark : public CustomPaintBenchmark {
87 public:
88 NullCanvasPaintBenchmark(const std::string& name,
89 WebViewBenchmarkSupport::PaintMode paint_mode)
90 : CustomPaintBenchmark(name, paint_mode) { }
91
92 private:
93 virtual WebCanvas* createCanvas(const WebSize& size) OVERRIDE {
94 return SkCreateNullCanvas();
95 }
96 };
97 } // anonymous namespace
98
99 namespace content {
100
101 ScopedVector<RenderingBenchmark> AllRenderingBenchmarks() {
102 ScopedVector<RenderingBenchmark> benchmarks;
103 benchmarks.push_back(new BitmapCanvasPaintBenchmark(
104 "PaintEverythingToBitmap",
105 WebViewBenchmarkSupport::PaintModeEverything));
106 benchmarks.push_back(new NullCanvasPaintBenchmark(
107 "PaintEverythingToNullCanvas",
108 WebViewBenchmarkSupport::PaintModeEverything));
109 return benchmarks.Pass();
110 }
111
112 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/all_rendering_benchmarks.h ('k') | content/renderer/gpu/gpu_benchmarking_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698