OLD | NEW |
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 void onDraw(const int loops, SkCanvas*) override { | 108 void onDraw(const 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 (NULL == objects[idx].get()) { | 117 if (nullptr == objects[idx].get()) { |
118 objects[idx].reset(new B); | 118 objects[idx].reset(new B); |
119 } else { | 119 } else { |
120 objects[idx].free(); | 120 objects[idx].free(); |
121 } | 121 } |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 private: | 125 private: |
126 typedef Benchmark INHERITED; | 126 typedef Benchmark INHERITED; |
127 }; | 127 }; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |