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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/all_rendering_benchmarks.cc
diff --git a/content/renderer/all_rendering_benchmarks.cc b/content/renderer/all_rendering_benchmarks.cc
new file mode 100644
index 0000000000000000000000000000000000000000..17edc72cc73da250b654998db112b9b72a3f5aea
--- /dev/null
+++ b/content/renderer/all_rendering_benchmarks.cc
@@ -0,0 +1,100 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/all_rendering_benchmarks.h"
+
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/time.h"
+#include "content/renderer/rendering_benchmark.h"
+#include "content/renderer/rendering_benchmark_results.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "third_party/skia/include/core/SkDevice.h"
+#include "third_party/skia/include/utils/SkNullCanvas.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebCanvas.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebViewBenchmarkSupport.h"
+
+using base::TimeDelta;
+using base::TimeTicks;
+using WebKit::WebSize;
+using WebKit::WebCanvas;
+using WebKit::WebViewBenchmarkSupport;
+
+namespace {
+typedef base::Callback<WebCanvas*(const WebSize&)> CanvasCallback;
+
+class CustomPaintBenchmark
+ : public content::RenderingBenchmark,
+ public WebViewBenchmarkSupport::PaintClient {
+ public:
+ CustomPaintBenchmark(const std::string& name,
+ WebViewBenchmarkSupport::PaintMode paint_mode)
+ : content::RenderingBenchmark(name),
+ paint_mode_(paint_mode) { }
+
+ virtual void willPaint(const WebCanvas& /* canvas */) {
+ beforeTime = TimeTicks::Now();
+ }
+
+ virtual void didPaint(const WebCanvas& /* canvas */) {
+ paintTimeTotal += (TimeTicks::Now() - beforeTime);
+ }
+
+ virtual void Run(content::RenderingBenchmarkResults* results,
+ WebViewBenchmarkSupport* support) {
+ paintTimeTotal = TimeDelta();
+ support->paint(this, paint_mode_);
+ results->addResult(name(), "paintTime", "s", paintTimeTotal.InSecondsF());
+ }
+
+ private:
+ TimeTicks beforeTime;
nduca 2012/07/20 20:30:09 beforeTime_ here and elsewhere, members get _
dmurph 2012/07/20 20:52:33 Done.
+ TimeDelta paintTimeTotal;
+ const WebViewBenchmarkSupport::PaintMode paint_mode_;
+};
+
+class BitmapCanvasPaintBenchmark : public CustomPaintBenchmark {
+ public:
+ BitmapCanvasPaintBenchmark(const std::string& name,
+ WebViewBenchmarkSupport::PaintMode paint_mode)
+ : CustomPaintBenchmark(name, paint_mode) { }
+
+ virtual WebCanvas* createCanvas(const WebSize& size) OVERRIDE {
+ SkDevice* device = new SkDevice(SkBitmap::kARGB_8888_Config,
+ size.width,
+ size.height,
+ false);
+ WebCanvas* canvas = new WebCanvas(device);
+ device->unref();
+ return canvas;
+ }
+};
+
+class NullCanvasPaintBenchmark : public CustomPaintBenchmark {
+ public:
+ NullCanvasPaintBenchmark(const std::string& name,
+ WebViewBenchmarkSupport::PaintMode paint_mode)
+ : CustomPaintBenchmark(name, paint_mode) { }
+
+ virtual WebCanvas* createCanvas(const WebSize& size) OVERRIDE {
+ return SkCreateNullCanvas();
+ }
+};
+} // anonymous namespace
+
+namespace content {
+
+std::vector<RenderingBenchmark*> AllRenderingBenchmarks() {
+ std::vector<RenderingBenchmark*> benchmarks;
+ benchmarks.push_back(new BitmapCanvasPaintBenchmark(
+ "PaintEverythingToBitmap",
+ WebViewBenchmarkSupport::PaintModeEverything));
+ benchmarks.push_back(new NullCanvasPaintBenchmark(
+ "PaintEverythingToNullCanvas",
+ WebViewBenchmarkSupport::PaintModeEverything));
+ return benchmarks;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698