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

Side by Side Diff: bench/GrMemoryPoolBench.cpp

Issue 73643005: Implement a benchmark for GrResourceCache (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month 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
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 // This tests a Gr class 8 // This tests a Gr class
9 #if SK_SUPPORT_GPU 9 #if SK_SUPPORT_GPU
10 10
(...skipping 15 matching lines...) Expand all
26 static GrMemoryPool gPool; 26 static GrMemoryPool gPool;
27 }; 27 };
28 GrMemoryPool A::gPool(10 * (1 << 10), 10 * (1 << 10)); 28 GrMemoryPool A::gPool(10 * (1 << 10), 10 * (1 << 10));
29 29
30 /** 30 /**
31 * This benchmark creates and deletes objects in stack order 31 * This benchmark creates and deletes objects in stack order
32 */ 32 */
33 class GrMemoryPoolBenchStack : public SkBenchmark { 33 class GrMemoryPoolBenchStack : public SkBenchmark {
34 public: 34 public:
35 GrMemoryPoolBenchStack() { 35 GrMemoryPoolBenchStack() {
36 fIsRendering = false;
37 } 36 }
37
38 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
39 return backend == kNonRendering_Backend;
40 }
41
38 protected: 42 protected:
39 virtual const char* onGetName() { 43 virtual const char* onGetName() {
40 return "grmemorypool_stack"; 44 return "grmemorypool_stack";
41 } 45 }
42 46
43 virtual void onDraw(SkCanvas*) { 47 virtual void onDraw(SkCanvas*) {
44 SkRandom r; 48 SkRandom r;
45 enum { 49 enum {
46 kMaxObjects = 4 * (1 << 10), 50 kMaxObjects = 4 * (1 << 10),
47 }; 51 };
(...skipping 29 matching lines...) Expand all
77 private: 81 private:
78 typedef SkBenchmark INHERITED; 82 typedef SkBenchmark INHERITED;
79 }; 83 };
80 84
81 /** 85 /**
82 * This benchmark creates objects and deletes them in random order 86 * This benchmark creates objects and deletes them in random order
83 */ 87 */
84 class GrMemoryPoolBenchRandom : public SkBenchmark { 88 class GrMemoryPoolBenchRandom : public SkBenchmark {
85 public: 89 public:
86 GrMemoryPoolBenchRandom() { 90 GrMemoryPoolBenchRandom() {
87 fIsRendering = false;
88 } 91 }
92
93 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
94 return backend == kNonRendering_Backend;
95 }
96
89 protected: 97 protected:
90 virtual const char* onGetName() { 98 virtual const char* onGetName() {
91 return "grmemorypool_random"; 99 return "grmemorypool_random";
92 } 100 }
93 101
94 virtual void onDraw(SkCanvas*) { 102 virtual void onDraw(SkCanvas*) {
95 SkRandom r; 103 SkRandom r;
96 enum { 104 enum {
97 kMaxObjects = 4 * (1 << 10), 105 kMaxObjects = 4 * (1 << 10),
98 }; 106 };
(...skipping 15 matching lines...) Expand all
114 122
115 /** 123 /**
116 * This benchmark creates objects and deletes them in queue order 124 * This benchmark creates objects and deletes them in queue order
117 */ 125 */
118 class GrMemoryPoolBenchQueue : public SkBenchmark { 126 class GrMemoryPoolBenchQueue : public SkBenchmark {
119 enum { 127 enum {
120 M = 4 * (1 << 10), 128 M = 4 * (1 << 10),
121 }; 129 };
122 public: 130 public:
123 GrMemoryPoolBenchQueue() { 131 GrMemoryPoolBenchQueue() {
124 fIsRendering = false;
125 } 132 }
133
134 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
135 return backend == kNonRendering_Backend;
136 }
137
126 protected: 138 protected:
127 virtual const char* onGetName() { 139 virtual const char* onGetName() {
128 return "grmemorypool_queue"; 140 return "grmemorypool_queue";
129 } 141 }
130 142
131 virtual void onDraw(SkCanvas*) { 143 virtual void onDraw(SkCanvas*) {
132 SkRandom r; 144 SkRandom r;
133 A* objects[M]; 145 A* objects[M];
134 for (int i = 0; i < this->getLoops(); i++) { 146 for (int i = 0; i < this->getLoops(); i++) {
135 uint32_t count = r.nextRangeU(0, M-1); 147 uint32_t count = r.nextRangeU(0, M-1);
(...skipping 10 matching lines...) Expand all
146 typedef SkBenchmark INHERITED; 158 typedef SkBenchmark INHERITED;
147 }; 159 };
148 160
149 /////////////////////////////////////////////////////////////////////////////// 161 ///////////////////////////////////////////////////////////////////////////////
150 162
151 DEF_BENCH( return new GrMemoryPoolBenchStack(); ) 163 DEF_BENCH( return new GrMemoryPoolBenchStack(); )
152 DEF_BENCH( return new GrMemoryPoolBenchRandom(); ) 164 DEF_BENCH( return new GrMemoryPoolBenchRandom(); )
153 DEF_BENCH( return new GrMemoryPoolBenchQueue(); ) 165 DEF_BENCH( return new GrMemoryPoolBenchQueue(); )
154 166
155 #endif 167 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698