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

Side by Side Diff: bench/GrResourceCacheBench.cpp

Issue 1037793002: C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: git cl web Created 5 years, 9 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/HairlinePathBench.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 #include "Benchmark.h" 9 #include "Benchmark.h"
10 10
(...skipping 18 matching lines...) Expand all
29 this->registerWithCache(); 29 this->registerWithCache();
30 } 30 }
31 31
32 static void ComputeKey(int i, GrUniqueKey* key) { 32 static void ComputeKey(int i, GrUniqueKey* key) {
33 static GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); 33 static GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
34 GrUniqueKey::Builder builder(key, kDomain, 1); 34 GrUniqueKey::Builder builder(key, kDomain, 1);
35 builder[0] = i; 35 builder[0] = i;
36 } 36 }
37 37
38 private: 38 private:
39 size_t onGpuMemorySize() const SK_OVERRIDE { return 100; } 39 size_t onGpuMemorySize() const override { return 100; }
40 40
41 typedef GrGpuResource INHERITED; 41 typedef GrGpuResource INHERITED;
42 }; 42 };
43 43
44 static void populate_cache(GrGpu* gpu, int resourceCount) { 44 static void populate_cache(GrGpu* gpu, int resourceCount) {
45 for (int i = 0; i < resourceCount; ++i) { 45 for (int i = 0; i < resourceCount; ++i) {
46 GrUniqueKey key; 46 GrUniqueKey key;
47 BenchResource::ComputeKey(i, &key); 47 BenchResource::ComputeKey(i, &key);
48 GrGpuResource* resource = SkNEW_ARGS(BenchResource, (gpu)); 48 GrGpuResource* resource = SkNEW_ARGS(BenchResource, (gpu));
49 resource->resourcePriv().setUniqueKey(key); 49 resource->resourcePriv().setUniqueKey(key);
50 resource->unref(); 50 resource->unref();
51 } 51 }
52 } 52 }
53 53
54 class GrResourceCacheBenchAdd : public Benchmark { 54 class GrResourceCacheBenchAdd : public Benchmark {
55 public: 55 public:
56 bool isSuitableFor(Backend backend) SK_OVERRIDE { 56 bool isSuitableFor(Backend backend) override {
57 return backend == kNonRendering_Backend; 57 return backend == kNonRendering_Backend;
58 } 58 }
59 59
60 protected: 60 protected:
61 const char* onGetName() SK_OVERRIDE { 61 const char* onGetName() override {
62 return "grresourcecache_add"; 62 return "grresourcecache_add";
63 } 63 }
64 64
65 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { 65 void onDraw(const int loops, SkCanvas* canvas) override {
66 SkAutoTUnref<GrContext> context(GrContext::CreateMockContext()); 66 SkAutoTUnref<GrContext> context(GrContext::CreateMockContext());
67 if (NULL == context) { 67 if (NULL == context) {
68 return; 68 return;
69 } 69 }
70 // Set the cache budget to be very large so no purging occurs. 70 // Set the cache budget to be very large so no purging occurs.
71 context->setResourceCacheLimits(CACHE_SIZE_COUNT, 1 << 30); 71 context->setResourceCacheLimits(CACHE_SIZE_COUNT, 1 << 30);
72 72
73 GrResourceCache* cache = context->getResourceCache(); 73 GrResourceCache* cache = context->getResourceCache();
74 74
75 // Make sure the cache is empty. 75 // Make sure the cache is empty.
76 cache->purgeAllUnlocked(); 76 cache->purgeAllUnlocked();
77 SkASSERT(0 == cache->getResourceCount() && 0 == cache->getResourceBytes( )); 77 SkASSERT(0 == cache->getResourceCount() && 0 == cache->getResourceBytes( ));
78 78
79 GrGpu* gpu = context->getGpu(); 79 GrGpu* gpu = context->getGpu();
80 80
81 for (int i = 0; i < loops; ++i) { 81 for (int i = 0; i < loops; ++i) {
82 populate_cache(gpu, CACHE_SIZE_COUNT); 82 populate_cache(gpu, CACHE_SIZE_COUNT);
83 SkASSERT(CACHE_SIZE_COUNT == cache->getResourceCount()); 83 SkASSERT(CACHE_SIZE_COUNT == cache->getResourceCount());
84 } 84 }
85 } 85 }
86 86
87 private: 87 private:
88 typedef Benchmark INHERITED; 88 typedef Benchmark INHERITED;
89 }; 89 };
90 90
91 class GrResourceCacheBenchFind : public Benchmark { 91 class GrResourceCacheBenchFind : public Benchmark {
92 public: 92 public:
93 bool isSuitableFor(Backend backend) SK_OVERRIDE { 93 bool isSuitableFor(Backend backend) override {
94 return backend == kNonRendering_Backend; 94 return backend == kNonRendering_Backend;
95 } 95 }
96 96
97 protected: 97 protected:
98 const char* onGetName() SK_OVERRIDE { 98 const char* onGetName() override {
99 return "grresourcecache_find"; 99 return "grresourcecache_find";
100 } 100 }
101 101
102 void onPreDraw() SK_OVERRIDE { 102 void onPreDraw() override {
103 fContext.reset(GrContext::CreateMockContext()); 103 fContext.reset(GrContext::CreateMockContext());
104 if (!fContext) { 104 if (!fContext) {
105 return; 105 return;
106 } 106 }
107 // Set the cache budget to be very large so no purging occurs. 107 // Set the cache budget to be very large so no purging occurs.
108 fContext->setResourceCacheLimits(CACHE_SIZE_COUNT, 1 << 30); 108 fContext->setResourceCacheLimits(CACHE_SIZE_COUNT, 1 << 30);
109 109
110 GrResourceCache* cache = fContext->getResourceCache(); 110 GrResourceCache* cache = fContext->getResourceCache();
111 111
112 // Make sure the cache is empty. 112 // Make sure the cache is empty.
113 cache->purgeAllUnlocked(); 113 cache->purgeAllUnlocked();
114 SkASSERT(0 == cache->getResourceCount() && 0 == cache->getResourceBytes( )); 114 SkASSERT(0 == cache->getResourceCount() && 0 == cache->getResourceBytes( ));
115 115
116 GrGpu* gpu = fContext->getGpu(); 116 GrGpu* gpu = fContext->getGpu();
117 117
118 populate_cache(gpu, CACHE_SIZE_COUNT); 118 populate_cache(gpu, CACHE_SIZE_COUNT);
119 } 119 }
120 120
121 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { 121 void onDraw(const int loops, SkCanvas* canvas) override {
122 if (!fContext) { 122 if (!fContext) {
123 return; 123 return;
124 } 124 }
125 GrResourceCache* cache = fContext->getResourceCache(); 125 GrResourceCache* cache = fContext->getResourceCache();
126 SkASSERT(CACHE_SIZE_COUNT == cache->getResourceCount()); 126 SkASSERT(CACHE_SIZE_COUNT == cache->getResourceCount());
127 for (int i = 0; i < loops; ++i) { 127 for (int i = 0; i < loops; ++i) {
128 for (int k = 0; k < CACHE_SIZE_COUNT; ++k) { 128 for (int k = 0; k < CACHE_SIZE_COUNT; ++k) {
129 GrUniqueKey key; 129 GrUniqueKey key;
130 BenchResource::ComputeKey(k, &key); 130 BenchResource::ComputeKey(k, &key);
131 SkAutoTUnref<GrGpuResource> resource(cache->findAndRefUniqueReso urce(key)); 131 SkAutoTUnref<GrGpuResource> resource(cache->findAndRefUniqueReso urce(key));
132 SkASSERT(resource); 132 SkASSERT(resource);
133 } 133 }
134 } 134 }
135 } 135 }
136 136
137 private: 137 private:
138 SkAutoTUnref<GrContext> fContext; 138 SkAutoTUnref<GrContext> fContext;
139 typedef Benchmark INHERITED; 139 typedef Benchmark INHERITED;
140 }; 140 };
141 141
142 DEF_BENCH( return new GrResourceCacheBenchAdd(); ) 142 DEF_BENCH( return new GrResourceCacheBenchAdd(); )
143 DEF_BENCH( return new GrResourceCacheBenchFind(); ) 143 DEF_BENCH( return new GrResourceCacheBenchFind(); )
144 144
145 #endif 145 #endif
OLDNEW
« no previous file with comments | « bench/GrOrderedSetBench.cpp ('k') | bench/HairlinePathBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698