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

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: address comments 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
« no previous file with comments | « bench/DecodeBench.cpp ('k') | bench/GrResourceCacheBench.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 // This tests a Gr class 8 // This tests a Gr class
9 #if SK_SUPPORT_GPU 9 #if SK_SUPPORT_GPU
10 10
(...skipping 14 matching lines...) Expand all
25 #endif 25 #endif
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 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
36 fIsRendering = false; 36 return backend == kNonRendering_Backend;
37 } 37 }
38
38 protected: 39 protected:
39 virtual const char* onGetName() { 40 virtual const char* onGetName() {
40 return "grmemorypool_stack"; 41 return "grmemorypool_stack";
41 } 42 }
42 43
43 virtual void onDraw(SkCanvas*) { 44 virtual void onDraw(SkCanvas*) {
44 SkRandom r; 45 SkRandom r;
45 enum { 46 enum {
46 kMaxObjects = 4 * (1 << 10), 47 kMaxObjects = 4 * (1 << 10),
47 }; 48 };
(...skipping 28 matching lines...) Expand all
76 77
77 private: 78 private:
78 typedef SkBenchmark INHERITED; 79 typedef SkBenchmark INHERITED;
79 }; 80 };
80 81
81 /** 82 /**
82 * This benchmark creates objects and deletes them in random order 83 * This benchmark creates objects and deletes them in random order
83 */ 84 */
84 class GrMemoryPoolBenchRandom : public SkBenchmark { 85 class GrMemoryPoolBenchRandom : public SkBenchmark {
85 public: 86 public:
86 GrMemoryPoolBenchRandom() { 87 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
87 fIsRendering = false; 88 return backend == kNonRendering_Backend;
88 } 89 }
90
89 protected: 91 protected:
90 virtual const char* onGetName() { 92 virtual const char* onGetName() {
91 return "grmemorypool_random"; 93 return "grmemorypool_random";
92 } 94 }
93 95
94 virtual void onDraw(SkCanvas*) { 96 virtual void onDraw(SkCanvas*) {
95 SkRandom r; 97 SkRandom r;
96 enum { 98 enum {
97 kMaxObjects = 4 * (1 << 10), 99 kMaxObjects = 4 * (1 << 10),
98 }; 100 };
(...skipping 14 matching lines...) Expand all
113 }; 115 };
114 116
115 /** 117 /**
116 * This benchmark creates objects and deletes them in queue order 118 * This benchmark creates objects and deletes them in queue order
117 */ 119 */
118 class GrMemoryPoolBenchQueue : public SkBenchmark { 120 class GrMemoryPoolBenchQueue : public SkBenchmark {
119 enum { 121 enum {
120 M = 4 * (1 << 10), 122 M = 4 * (1 << 10),
121 }; 123 };
122 public: 124 public:
123 GrMemoryPoolBenchQueue() { 125 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
124 fIsRendering = false; 126 return backend == kNonRendering_Backend;
125 } 127 }
128
126 protected: 129 protected:
127 virtual const char* onGetName() { 130 virtual const char* onGetName() {
128 return "grmemorypool_queue"; 131 return "grmemorypool_queue";
129 } 132 }
130 133
131 virtual void onDraw(SkCanvas*) { 134 virtual void onDraw(SkCanvas*) {
132 SkRandom r; 135 SkRandom r;
133 A* objects[M]; 136 A* objects[M];
134 for (int i = 0; i < this->getLoops(); i++) { 137 for (int i = 0; i < this->getLoops(); i++) {
135 uint32_t count = r.nextRangeU(0, M-1); 138 uint32_t count = r.nextRangeU(0, M-1);
(...skipping 10 matching lines...) Expand all
146 typedef SkBenchmark INHERITED; 149 typedef SkBenchmark INHERITED;
147 }; 150 };
148 151
149 /////////////////////////////////////////////////////////////////////////////// 152 ///////////////////////////////////////////////////////////////////////////////
150 153
151 DEF_BENCH( return new GrMemoryPoolBenchStack(); ) 154 DEF_BENCH( return new GrMemoryPoolBenchStack(); )
152 DEF_BENCH( return new GrMemoryPoolBenchRandom(); ) 155 DEF_BENCH( return new GrMemoryPoolBenchRandom(); )
153 DEF_BENCH( return new GrMemoryPoolBenchQueue(); ) 156 DEF_BENCH( return new GrMemoryPoolBenchQueue(); )
154 157
155 #endif 158 #endif
OLDNEW
« no previous file with comments | « bench/DecodeBench.cpp ('k') | bench/GrResourceCacheBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698