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

Side by Side Diff: bench/GrMemoryPoolBench.cpp

Issue 1379923005: Remove const from `const int loops`. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: n too Created 5 years, 2 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/GeometryBench.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 #include "SkTypes.h" 8 #include "SkTypes.h"
9 9
10 // This tests a Gr class 10 // This tests a Gr class
(...skipping 25 matching lines...) Expand all
36 public: 36 public:
37 bool isSuitableFor(Backend backend) override { 37 bool isSuitableFor(Backend backend) override {
38 return backend == kNonRendering_Backend; 38 return backend == kNonRendering_Backend;
39 } 39 }
40 40
41 protected: 41 protected:
42 const char* onGetName() override { 42 const char* onGetName() override {
43 return "grmemorypool_stack"; 43 return "grmemorypool_stack";
44 } 44 }
45 45
46 void onDraw(const int loops, SkCanvas*) override { 46 void onDraw(int loops, SkCanvas*) override {
47 SkRandom r; 47 SkRandom r;
48 enum { 48 enum {
49 kMaxObjects = 4 * (1 << 10), 49 kMaxObjects = 4 * (1 << 10),
50 }; 50 };
51 A* objects[kMaxObjects]; 51 A* objects[kMaxObjects];
52 52
53 // 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,
54 // 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
55 SkFixed delThresh = -SK_FixedHalf; 55 SkFixed delThresh = -SK_FixedHalf;
56 const int kSwitchThreshPeriod = loops / (2 * kMaxObjects); 56 const int kSwitchThreshPeriod = loops / (2 * kMaxObjects);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 public: 98 public:
99 bool isSuitableFor(Backend backend) override { 99 bool isSuitableFor(Backend backend) override {
100 return backend == kNonRendering_Backend; 100 return backend == kNonRendering_Backend;
101 } 101 }
102 102
103 protected: 103 protected:
104 const char* onGetName() override { 104 const char* onGetName() override {
105 return "grmemorypool_random"; 105 return "grmemorypool_random";
106 } 106 }
107 107
108 void onDraw(const int loops, SkCanvas*) override { 108 void onDraw(int loops, SkCanvas*) override {
109 SkRandom r; 109 SkRandom r;
110 enum { 110 enum {
111 kMaxObjects = 4 * (1 << 10), 111 kMaxObjects = 4 * (1 << 10),
112 }; 112 };
113 SkAutoTDelete<B> objects[kMaxObjects]; 113 SkAutoTDelete<B> objects[kMaxObjects];
114 114
115 for (int i = 0; i < loops; i++) { 115 for (int i = 0; i < loops; i++) {
116 uint32_t idx = r.nextRangeU(0, kMaxObjects-1); 116 uint32_t idx = r.nextRangeU(0, kMaxObjects-1);
117 if (nullptr == objects[idx].get()) { 117 if (nullptr == objects[idx].get()) {
118 objects[idx].reset(new B); 118 objects[idx].reset(new B);
(...skipping 27 matching lines...) Expand all
146 public: 146 public:
147 bool isSuitableFor(Backend backend) override { 147 bool isSuitableFor(Backend backend) override {
148 return backend == kNonRendering_Backend; 148 return backend == kNonRendering_Backend;
149 } 149 }
150 150
151 protected: 151 protected:
152 const char* onGetName() override { 152 const char* onGetName() override {
153 return "grmemorypool_queue"; 153 return "grmemorypool_queue";
154 } 154 }
155 155
156 void onDraw(const int loops, SkCanvas*) override { 156 void onDraw(int loops, SkCanvas*) override {
157 SkRandom r; 157 SkRandom r;
158 C* objects[M]; 158 C* objects[M];
159 for (int i = 0; i < loops; i++) { 159 for (int i = 0; i < loops; i++) {
160 uint32_t count = r.nextRangeU(0, M-1); 160 uint32_t count = r.nextRangeU(0, M-1);
161 for (uint32_t i = 0; i < count; i++) { 161 for (uint32_t i = 0; i < count; i++) {
162 objects[i] = new C; 162 objects[i] = new C;
163 } 163 }
164 for (uint32_t i = 0; i < count; i++) { 164 for (uint32_t i = 0; i < count; i++) {
165 delete objects[i]; 165 delete objects[i];
166 } 166 }
167 } 167 }
168 } 168 }
169 169
170 private: 170 private:
171 typedef Benchmark INHERITED; 171 typedef Benchmark INHERITED;
172 }; 172 };
173 173
174 /////////////////////////////////////////////////////////////////////////////// 174 ///////////////////////////////////////////////////////////////////////////////
175 175
176 DEF_BENCH( return new GrMemoryPoolBenchStack(); ) 176 DEF_BENCH( return new GrMemoryPoolBenchStack(); )
177 DEF_BENCH( return new GrMemoryPoolBenchRandom(); ) 177 DEF_BENCH( return new GrMemoryPoolBenchRandom(); )
178 DEF_BENCH( return new GrMemoryPoolBenchQueue(); ) 178 DEF_BENCH( return new GrMemoryPoolBenchQueue(); )
179 179
180 #endif 180 #endif
OLDNEW
« no previous file with comments | « bench/GeometryBench.cpp ('k') | bench/GrResourceCacheBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698