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

Side by Side Diff: bench/GrMemoryPoolBench.cpp

Issue 1232463006: Fix up -Winconsistent-missing-override (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: llvm_coverage_build Created 5 years, 5 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/ChecksumBench.cpp ('k') | bench/InterpBench.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 "SkTypes.h"
9
8 // This tests a Gr class 10 // This tests a Gr class
9 #if SK_SUPPORT_GPU 11 #if SK_SUPPORT_GPU
10 12
11 #include "Benchmark.h" 13 #include "Benchmark.h"
12 #include "GrMemoryPool.h" 14 #include "GrMemoryPool.h"
13 #include "SkRandom.h" 15 #include "SkRandom.h"
14 #include "SkTDArray.h" 16 #include "SkTDArray.h"
15 #include "SkTemplates.h" 17 #include "SkTemplates.h"
16 18
17 // change this to 0 to compare GrMemoryPool to default new / delete 19 // change this to 0 to compare GrMemoryPool to default new / delete
(...skipping 12 matching lines...) Expand all
30 /** 32 /**
31 * This benchmark creates and deletes objects in stack order 33 * This benchmark creates and deletes objects in stack order
32 */ 34 */
33 class GrMemoryPoolBenchStack : public Benchmark { 35 class GrMemoryPoolBenchStack : public Benchmark {
34 public: 36 public:
35 bool isSuitableFor(Backend backend) override { 37 bool isSuitableFor(Backend backend) override {
36 return backend == kNonRendering_Backend; 38 return backend == kNonRendering_Backend;
37 } 39 }
38 40
39 protected: 41 protected:
40 virtual const char* onGetName() { 42 const char* onGetName() override {
41 return "grmemorypool_stack"; 43 return "grmemorypool_stack";
42 } 44 }
43 45
44 virtual void onDraw(const int loops, SkCanvas*) { 46 void onDraw(const int loops, SkCanvas*) override {
45 SkRandom r; 47 SkRandom r;
46 enum { 48 enum {
47 kMaxObjects = 4 * (1 << 10), 49 kMaxObjects = 4 * (1 << 10),
48 }; 50 };
49 A* objects[kMaxObjects]; 51 A* objects[kMaxObjects];
50 52
51 // We delete if a random [-1, 1] fixed pt is < the thresh. Otherwise, 53 // We delete if a random [-1, 1] fixed pt is < the thresh. Otherwise,
52 // we allocate. We start allocate-biased and ping-pong to delete-biased 54 // we allocate. We start allocate-biased and ping-pong to delete-biased
53 SkFixed delThresh = -SK_FixedHalf; 55 SkFixed delThresh = -SK_FixedHalf;
54 const int kSwitchThreshPeriod = loops / (2 * kMaxObjects); 56 const int kSwitchThreshPeriod = loops / (2 * kMaxObjects);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 /** 94 /**
93 * This benchmark creates objects and deletes them in random order 95 * This benchmark creates objects and deletes them in random order
94 */ 96 */
95 class GrMemoryPoolBenchRandom : public Benchmark { 97 class GrMemoryPoolBenchRandom : public Benchmark {
96 public: 98 public:
97 bool isSuitableFor(Backend backend) override { 99 bool isSuitableFor(Backend backend) override {
98 return backend == kNonRendering_Backend; 100 return backend == kNonRendering_Backend;
99 } 101 }
100 102
101 protected: 103 protected:
102 virtual const char* onGetName() { 104 const char* onGetName() override {
103 return "grmemorypool_random"; 105 return "grmemorypool_random";
104 } 106 }
105 107
106 virtual void onDraw(const int loops, SkCanvas*) { 108 void onDraw(const int loops, SkCanvas*) override {
107 SkRandom r; 109 SkRandom r;
108 enum { 110 enum {
109 kMaxObjects = 4 * (1 << 10), 111 kMaxObjects = 4 * (1 << 10),
110 }; 112 };
111 SkAutoTDelete<B> objects[kMaxObjects]; 113 SkAutoTDelete<B> objects[kMaxObjects];
112 114
113 for (int i = 0; i < loops; i++) { 115 for (int i = 0; i < loops; i++) {
114 uint32_t idx = r.nextRangeU(0, kMaxObjects-1); 116 uint32_t idx = r.nextRangeU(0, kMaxObjects-1);
115 if (NULL == objects[idx].get()) { 117 if (NULL == objects[idx].get()) {
116 objects[idx].reset(new B); 118 objects[idx].reset(new B);
(...skipping 23 matching lines...) Expand all
140 class GrMemoryPoolBenchQueue : public Benchmark { 142 class GrMemoryPoolBenchQueue : public Benchmark {
141 enum { 143 enum {
142 M = 4 * (1 << 10), 144 M = 4 * (1 << 10),
143 }; 145 };
144 public: 146 public:
145 bool isSuitableFor(Backend backend) override { 147 bool isSuitableFor(Backend backend) override {
146 return backend == kNonRendering_Backend; 148 return backend == kNonRendering_Backend;
147 } 149 }
148 150
149 protected: 151 protected:
150 virtual const char* onGetName() { 152 const char* onGetName() override {
151 return "grmemorypool_queue"; 153 return "grmemorypool_queue";
152 } 154 }
153 155
154 virtual void onDraw(const int loops, SkCanvas*) { 156 void onDraw(const int loops, SkCanvas*) override {
155 SkRandom r; 157 SkRandom r;
156 C* objects[M]; 158 C* objects[M];
157 for (int i = 0; i < loops; i++) { 159 for (int i = 0; i < loops; i++) {
158 uint32_t count = r.nextRangeU(0, M-1); 160 uint32_t count = r.nextRangeU(0, M-1);
159 for (uint32_t i = 0; i < count; i++) { 161 for (uint32_t i = 0; i < count; i++) {
160 objects[i] = new C; 162 objects[i] = new C;
161 } 163 }
162 for (uint32_t i = 0; i < count; i++) { 164 for (uint32_t i = 0; i < count; i++) {
163 delete objects[i]; 165 delete objects[i];
164 } 166 }
165 } 167 }
166 } 168 }
167 169
168 private: 170 private:
169 typedef Benchmark INHERITED; 171 typedef Benchmark INHERITED;
170 }; 172 };
171 173
172 /////////////////////////////////////////////////////////////////////////////// 174 ///////////////////////////////////////////////////////////////////////////////
173 175
174 DEF_BENCH( return new GrMemoryPoolBenchStack(); ) 176 DEF_BENCH( return new GrMemoryPoolBenchStack(); )
175 DEF_BENCH( return new GrMemoryPoolBenchRandom(); ) 177 DEF_BENCH( return new GrMemoryPoolBenchRandom(); )
176 DEF_BENCH( return new GrMemoryPoolBenchQueue(); ) 178 DEF_BENCH( return new GrMemoryPoolBenchQueue(); )
177 179
178 #endif 180 #endif
OLDNEW
« no previous file with comments | « bench/ChecksumBench.cpp ('k') | bench/InterpBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698