aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/BitmapRectBench.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-01 15:58:07 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-01 15:58:07 +0000
commit7fb83c8c72f2a035e84a4ee4ee6abcf5a4872166 (patch)
treea47ea30d8bb00b811e7360992602e14bed7987c6 /bench/BitmapRectBench.cpp
parentab44a17f376039cdcaba74f9fb8f282ea4caa63c (diff)
When skia run bench cases to test performance, it will run constructors for all cases one by one, then getName to skip unnecessary cases according to command line parameters, so these constructors should be lightweight enough to avoid redundant computing. Unfortunately, some constructors contain intensive computing/rendering. They are very heavy, maybe much heavier than need-to-run bench case itself. And these redundant computation will be run every time you run bench, even you just test a single simple case. Moreover, it will mislead the real hotspot/bottleneck of the case itself.
For example, run a lightweight case, say, region_intersectsrgn_16, the hot spots are gles operation, SuperBlitter, SkRTree... introduced by irrelevant cases' constructors. These redundant computation will mislead performance tuning. So we can move these intensive computation to onPreDraw() of these case. They will be executed only if this case should be run. R=reed@google.com, robertphillips@google.com, humper@google.com, tomhudson@chromium.org Author: yunchao.he@intel.com Review URL: https://chromiumcodereview.appspot.com/20997003 git-svn-id: http://skia.googlecode.com/svn/trunk@10486 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench/BitmapRectBench.cpp')
-rw-r--r--bench/BitmapRectBench.cpp37
1 files changed, 20 insertions, 17 deletions
diff --git a/bench/BitmapRectBench.cpp b/bench/BitmapRectBench.cpp
index f9f46b817c..c147da2349 100644
--- a/bench/BitmapRectBench.cpp
+++ b/bench/BitmapRectBench.cpp
@@ -13,7 +13,7 @@
#include "SkRandom.h"
#include "SkString.h"
-static void drawIntoBitmap(const SkBitmap& bm) {
+static void draw_into_bitmap(const SkBitmap& bm) {
const int w = bm.width();
const int h = bm.height();
@@ -45,6 +45,8 @@ class BitmapRectBench : public SkBenchmark {
uint8_t fAlpha;
SkString fName;
SkRect fSrcR, fDstR;
+ static const int kWidth = 128;
+ static const int kHeight = 128;
enum { N = SkBENCHLOOP(300) };
public:
BitmapRectBench(void* param, U8CPU alpha, bool doFilter, bool slightMatrix) : INHERITED(param) {
@@ -52,37 +54,38 @@ public:
fDoFilter = doFilter;
fSlightMatrix = slightMatrix;
- const int w = 128;
- const int h = 128;
+ fBitmap.setConfig(SkBitmap::kARGB_8888_Config, kWidth, kHeight);
+ }
+
+protected:
+ virtual const char* onGetName() SK_OVERRIDE {
+ fName.printf("bitmaprect_%02X_%sfilter_%s",
+ fAlpha, fDoFilter ? "" : "no",
+ fSlightMatrix ? "trans" : "identity");
+ return fName.c_str();
+ }
- fBitmap.setConfig(SkBitmap::kARGB_8888_Config, w, h);
+ virtual void onPreDraw() SK_OVERRIDE {
fBitmap.allocPixels();
fBitmap.setIsOpaque(true);
fBitmap.eraseColor(SK_ColorBLACK);
- drawIntoBitmap(fBitmap);
+ draw_into_bitmap(fBitmap);
- fSrcR.iset(0, 0, w, h);
- fDstR.iset(0, 0, w, h);
+ fSrcR.iset(0, 0, kWidth, kHeight);
+ fDstR.iset(0, 0, kWidth, kHeight);
- if (slightMatrix) {
+ if (fSlightMatrix) {
// want fractional translate
fDstR.offset(SK_Scalar1 / 3, SK_Scalar1 * 5 / 7);
// want enough to create a scale matrix, but not enough to scare
// off our sniffer which tries to see if the matrix is "effectively"
// translate-only.
- fDstR.fRight += SK_Scalar1 / (w * 60);
+ fDstR.fRight += SK_Scalar1 / (kWidth * 60);
}
}
-protected:
- virtual const char* onGetName() {
- fName.printf("bitmaprect_%02X_%sfilter_%s",
- fAlpha, fDoFilter ? "" : "no",
- fSlightMatrix ? "trans" : "identity");
- return fName.c_str();
- }
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkRandom rand;
SkPaint paint;