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

Side by Side Diff: bench/TableBench.cpp

Issue 23478013: Major bench refactoring. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: merge with head agani Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « bench/StrokeBench.cpp ('k') | bench/TextBench.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBenchmark.h" 8 #include "SkBenchmark.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkRect.h" 10 #include "SkRect.h"
11 11
12 static const SkScalar kCellWidth = SkIntToScalar(20); 12 static const SkScalar kCellWidth = SkIntToScalar(20);
13 static const SkScalar kCellHeight = SkIntToScalar(10); 13 static const SkScalar kCellHeight = SkIntToScalar(10);
14 14
15 // This bench draws a table in the manner of Google spreadsheet and sahadan.com. 15 // This bench draws a table in the manner of Google spreadsheet and sahadan.com.
16 // ____________ ___ 16 // ____________ ___
17 // | 1 | 2 | 17 // | 1 | 2 |
18 // |____________|___| 18 // |____________|___|
19 // | 3 | 4 | 19 // | 3 | 4 |
20 // |____________|___| 20 // |____________|___|
21 // 21 //
22 // Areas 1-4 are first all draw white. Areas 3&4 are then drawn grey. Areas 22 // Areas 1-4 are first all draw white. Areas 3&4 are then drawn grey. Areas
23 // 2&4 are then drawn grey. Areas 2&3 are thus double drawn while area 4 is 23 // 2&4 are then drawn grey. Areas 2&3 are thus double drawn while area 4 is
24 // triple drawn. 24 // triple drawn.
25 // This trio of drawRects is then repeat for the next cell. 25 // This trio of drawRects is then repeat for the next cell.
26 class TableBench : public SkBenchmark { 26 class TableBench : public SkBenchmark {
27 public: 27 public:
28
29 static const int kNumIterations = SkBENCHLOOP(10);
30 static const int kNumRows = 48; 28 static const int kNumRows = 48;
31 static const int kNumCols = 32; 29 static const int kNumCols = 32;
32 30
33 TableBench(void* param) 31 TableBench(void* param)
34 : INHERITED(param) { 32 : INHERITED(param) {
35 } 33 }
36 34
37 protected: 35 protected:
38 virtual const char* onGetName() { 36 virtual const char* onGetName() {
39 return "tablebench"; 37 return "tablebench";
40 } 38 }
41 39
42 virtual void onDraw(SkCanvas* canvas) { 40 virtual void onDraw(SkCanvas* canvas) {
43
44 SkPaint cellPaint; 41 SkPaint cellPaint;
45 cellPaint.setColor(0xFFFFFFF); 42 cellPaint.setColor(0xFFFFFFF);
46 43
47 SkPaint borderPaint; 44 SkPaint borderPaint;
48 borderPaint.setColor(0xFFCCCCCC); 45 borderPaint.setColor(0xFFCCCCCC);
49 46
50 for (int i = 0; i < kNumIterations; ++i) { 47 for (int i = 0; i < this->getLoops(); ++i) {
51 for (int row = 0; row < kNumRows; ++row) { 48 for (int row = 0; row < kNumRows; ++row) {
52 for (int col = 0; col < kNumCols; ++col) { 49 for (int col = 0; col < kNumCols; ++col) {
53 SkRect cell = SkRect::MakeLTRB(col * kCellWidth, 50 SkRect cell = SkRect::MakeLTRB(col * kCellWidth,
54 row * kCellHeight, 51 row * kCellHeight,
55 (col+1) * kCellWidth, 52 (col+1) * kCellWidth,
56 (row+1) * kCellHeight); 53 (row+1) * kCellHeight);
57 canvas->drawRect(cell, cellPaint); 54 canvas->drawRect(cell, cellPaint);
58 55
59 SkRect bottom = SkRect::MakeLTRB(col * kCellWidth, 56 SkRect bottom = SkRect::MakeLTRB(col * kCellWidth,
60 row * kCellHeight + (kCellH eight-SK_Scalar1), 57 row * kCellHeight + (kCellH eight-SK_Scalar1),
(...skipping 11 matching lines...) Expand all
72 } 69 }
73 } 70 }
74 71
75 private: 72 private:
76 typedef SkBenchmark INHERITED; 73 typedef SkBenchmark INHERITED;
77 }; 74 };
78 75
79 static SkBenchmark* gFactory(void* p) { return new TableBench(p); } 76 static SkBenchmark* gFactory(void* p) { return new TableBench(p); }
80 77
81 static BenchRegistry gRegistry(gFactory); 78 static BenchRegistry gRegistry(gFactory);
OLDNEW
« no previous file with comments | « bench/StrokeBench.cpp ('k') | bench/TextBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698