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

Side by Side Diff: bench/GrResourceCacheBench.cpp

Issue 347823004: Remove Sk prefix from some bench classes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: SkGMBench -> GMBench Created 6 years, 6 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
« no previous file with comments | « bench/GrOrderedSetBench.cpp ('k') | bench/GradientBench.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 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #if SK_SUPPORT_GPU 9 #if SK_SUPPORT_GPU
10 10
11 #include "Benchmark.h"
12 #include "GrCacheable.h"
11 #include "GrContext.h" 13 #include "GrContext.h"
12 #include "GrCacheable.h"
13 #include "GrResourceCache.h" 14 #include "GrResourceCache.h"
14 #include "GrStencilBuffer.h" 15 #include "GrStencilBuffer.h"
15 #include "GrTexture.h" 16 #include "GrTexture.h"
16 #include "SkBenchmark.h"
17 #include "SkCanvas.h" 17 #include "SkCanvas.h"
18 18
19 enum { 19 enum {
20 CACHE_SIZE_COUNT = 2048, 20 CACHE_SIZE_COUNT = 2048,
21 CACHE_SIZE_BYTES = 2 * 1024 * 1024, 21 CACHE_SIZE_BYTES = 2 * 1024 * 1024,
22 }; 22 };
23 23
24 class StencilResource : public GrCacheable { 24 class StencilResource : public GrCacheable {
25 public: 25 public:
26 SK_DECLARE_INST_COUNT(StencilResource); 26 SK_DECLARE_INST_COUNT(StencilResource);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 h |= 1; 157 h |= 1;
158 GrResourceKey key = StencilResource::ComputeKey(w, h, s); 158 GrResourceKey key = StencilResource::ComputeKey(w, h, s);
159 GrCacheable* item = cache->find(key); 159 GrCacheable* item = cache->find(key);
160 if (NULL != item) { 160 if (NULL != item) {
161 SkFAIL("cache add does not work as expected"); 161 SkFAIL("cache add does not work as expected");
162 return; 162 return;
163 } 163 }
164 } 164 }
165 } 165 }
166 166
167 class GrResourceCacheBenchAdd : public SkBenchmark { 167 class GrResourceCacheBenchAdd : public Benchmark {
168 enum { 168 enum {
169 RESOURCE_COUNT = CACHE_SIZE_COUNT / 2, 169 RESOURCE_COUNT = CACHE_SIZE_COUNT / 2,
170 DUPLICATE_COUNT = CACHE_SIZE_COUNT / 4, 170 DUPLICATE_COUNT = CACHE_SIZE_COUNT / 4,
171 }; 171 };
172 172
173 public: 173 public:
174 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { 174 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
175 return backend == kGPU_Backend; 175 return backend == kGPU_Backend;
176 } 176 }
177 177
(...skipping 12 matching lines...) Expand all
190 190
191 // Check that cache works. 191 // Check that cache works.
192 for (int k = 0; k < RESOURCE_COUNT; k += 33) { 192 for (int k = 0; k < RESOURCE_COUNT; k += 33) {
193 check_cache_contents_or_die(&cache, k); 193 check_cache_contents_or_die(&cache, k);
194 } 194 }
195 cache.purgeAllUnlocked(); 195 cache.purgeAllUnlocked();
196 } 196 }
197 } 197 }
198 198
199 private: 199 private:
200 typedef SkBenchmark INHERITED; 200 typedef Benchmark INHERITED;
201 }; 201 };
202 202
203 class GrResourceCacheBenchFind : public SkBenchmark { 203 class GrResourceCacheBenchFind : public Benchmark {
204 enum { 204 enum {
205 RESOURCE_COUNT = (CACHE_SIZE_COUNT / 2) - 100, 205 RESOURCE_COUNT = (CACHE_SIZE_COUNT / 2) - 100,
206 DUPLICATE_COUNT = 100 206 DUPLICATE_COUNT = 100
207 }; 207 };
208 208
209 public: 209 public:
210 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { 210 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
211 return backend == kGPU_Backend; 211 return backend == kGPU_Backend;
212 } 212 }
213 213
214 protected: 214 protected:
215 virtual const char* onGetName() SK_OVERRIDE { 215 virtual const char* onGetName() SK_OVERRIDE {
216 return "grresourcecache_find"; 216 return "grresourcecache_find";
217 } 217 }
218 218
219 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { 219 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
220 GrGpu* gpu = canvas->getGrContext()->getGpu(); 220 GrGpu* gpu = canvas->getGrContext()->getGpu();
221 GrResourceCache cache(CACHE_SIZE_COUNT, CACHE_SIZE_BYTES); 221 GrResourceCache cache(CACHE_SIZE_COUNT, CACHE_SIZE_BYTES);
222 populate_cache(&cache, gpu, DUPLICATE_COUNT); 222 populate_cache(&cache, gpu, DUPLICATE_COUNT);
223 populate_cache(&cache, gpu, RESOURCE_COUNT); 223 populate_cache(&cache, gpu, RESOURCE_COUNT);
224 224
225 for (int i = 0; i < loops; ++i) { 225 for (int i = 0; i < loops; ++i) {
226 for (int k = 0; k < RESOURCE_COUNT; ++k) { 226 for (int k = 0; k < RESOURCE_COUNT; ++k) {
227 check_cache_contents_or_die(&cache, k); 227 check_cache_contents_or_die(&cache, k);
228 } 228 }
229 } 229 }
230 } 230 }
231 231
232 private: 232 private:
233 typedef SkBenchmark INHERITED; 233 typedef Benchmark INHERITED;
234 }; 234 };
235 235
236 DEF_BENCH( return new GrResourceCacheBenchAdd(); ) 236 DEF_BENCH( return new GrResourceCacheBenchAdd(); )
237 DEF_BENCH( return new GrResourceCacheBenchFind(); ) 237 DEF_BENCH( return new GrResourceCacheBenchFind(); )
238 238
239 #endif 239 #endif
OLDNEW
« no previous file with comments | « bench/GrOrderedSetBench.cpp ('k') | bench/GradientBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698