From 8f4269725bf4601965d803597b30766c611a9434 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Fri, 16 Aug 2013 00:40:34 +0000 Subject: [PATCH] This bench attempts to recreate Chromium's Canvas_putImageData performance test to track down https://code.google.com/p/chromium/issues/detail?id=270649. Cranking the repitition count up to 500 on a MacPro yields: WITHOUT 10624: running bench [640 480] writepix_rgba_UPM 8888: cmsecs = 748.25 GPU: cmsecs = 225.95 gmsecs = 244.80 running bench [640 480] writepix_rgba_PM 8888: cmsecs = 54.12 GPU: cmsecs = 225.77 gmsecs = 244.59 WITH 10624: running bench [640 480] writepix_rgba_UPM 8888: cmsecs = 747.70 GPU: cmsecs = 230.30 gmsecs = 249.51 running bench [640 480] writepix_rgba_PM 8888: cmsecs = 55.05 GPU: cmsecs = 230.13 gmsecs = 249.38 R=bsalomon@google.com Author: robertphillips@google.com Review URL: https://chromiumcodereview.appspot.com/22895012 git-svn-id: http://skia.googlecode.com/svn/trunk@10761 2bbb7eff-a529-9590-31e7-b0007b416f81 --- bench/WritePixelsBench.cpp | 77 ++++++++++++++++++++++++++++++++++++++ gyp/bench.gypi | 1 + 2 files changed, 78 insertions(+) create mode 100644 bench/WritePixelsBench.cpp diff --git a/bench/WritePixelsBench.cpp b/bench/WritePixelsBench.cpp new file mode 100644 index 0000000000..ea6f88cf6b --- /dev/null +++ b/bench/WritePixelsBench.cpp @@ -0,0 +1,77 @@ + +/* + * Copyright 2013 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkBenchmark.h" +#include "SkCanvas.h" +#include "SkConfig8888.h" +#include "SkString.h" + +class WritePixelsBench : public SkBenchmark { +public: + WritePixelsBench(void* param, SkCanvas::Config8888 config) + : INHERITED(param) + , fConfig(config) + , fName("writepix") { + switch (config) { + case SkCanvas::kNative_Premul_Config8888: + fName.append("_native_PM"); + break; + case SkCanvas::kNative_Unpremul_Config8888: + fName.append("_native_UPM"); + break; + case SkCanvas::kBGRA_Premul_Config8888: + fName.append("_bgra_PM"); + break; + case SkCanvas::kBGRA_Unpremul_Config8888: + fName.append("_bgra_UPM"); + break; + case SkCanvas::kRGBA_Premul_Config8888: + fName.append("_rgba_PM"); + break; + case SkCanvas::kRGBA_Unpremul_Config8888: + fName.append("_rgba_UPM"); + break; + default: + SK_CRASH(); + break; + } + } + +protected: + virtual const char* onGetName() SK_OVERRIDE { + return fName.c_str(); + } + + virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { + SkISize size = canvas->getDeviceSize(); + + canvas->clear(0xFFFF0000); + + SkBitmap bmp; + bmp.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height()); + canvas->readPixels(&bmp, 0, 0); + + for (int loop = 0; loop < kLoopCount; ++loop) { + canvas->writePixels(bmp, 0, 0, fConfig); + } + } + +private: + static const int kLoopCount = SkBENCHLOOP(50); + + SkCanvas::Config8888 fConfig; + SkString fName; + + typedef SkBenchmark INHERITED; +}; + +////////////////////////////////////////////////////////////////////////////// + +DEF_BENCH( return SkNEW_ARGS(WritePixelsBench, (p, SkCanvas::kRGBA_Premul_Config8888)); ) +DEF_BENCH( return SkNEW_ARGS(WritePixelsBench, (p, SkCanvas::kRGBA_Unpremul_Config8888)); ) + diff --git a/gyp/bench.gypi b/gyp/bench.gypi index 77ba56c4f6..bb2f942ca5 100644 --- a/gyp/bench.gypi +++ b/gyp/bench.gypi @@ -70,6 +70,7 @@ '../bench/VertBench.cpp', '../bench/WriterBench.cpp', '../bench/XfermodeBench.cpp', + '../bench/WritePixelsBench.cpp', '../bench/SkBenchLogger.h', '../bench/SkBenchLogger.cpp', -- 2.34.1