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 #include <memory> | 7 #include <memory> |
8 #include "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkRefCnt.h" | 9 #include "SkRefCnt.h" |
10 #include "SkThread.h" | 10 #include "SkThread.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 void operator delete(void*) { } | 184 void operator delete(void*) { } |
185 }; | 185 }; |
186 | 186 |
187 class WeakRefCntBench_Heap : public Benchmark { | 187 class WeakRefCntBench_Heap : public Benchmark { |
188 public: | 188 public: |
189 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { | 189 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
190 return backend == kNonRendering_Backend; | 190 return backend == kNonRendering_Backend; |
191 } | 191 } |
192 | 192 |
193 protected: | 193 protected: |
194 virtual const char* onGetName() { | 194 virtual const char* onGetName() SK_OVERRIDE { |
195 return "ref_cnt_heap_weak"; | 195 return "ref_cnt_heap_weak"; |
196 } | 196 } |
197 | 197 |
198 virtual void onDraw(const int loops, SkCanvas*) { | 198 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { |
199 char memory[sizeof(PlacedWeakRefCnt)]; | 199 char memory[sizeof(PlacedWeakRefCnt)]; |
200 for (int i = 0; i < loops; ++i) { | 200 for (int i = 0; i < loops; ++i) { |
201 PlacedWeakRefCnt* ref = new (memory) PlacedWeakRefCnt(); | 201 PlacedWeakRefCnt* ref = new (memory) PlacedWeakRefCnt(); |
202 for (int j = 0; j < M; ++j) { | 202 for (int j = 0; j < M; ++j) { |
203 ref->ref(); | 203 ref->ref(); |
204 ref->unref(); | 204 ref->unref(); |
205 } | 205 } |
206 ref->unref(); | 206 ref->unref(); |
207 } | 207 } |
208 } | 208 } |
209 | 209 |
210 private: | 210 private: |
211 typedef Benchmark INHERITED; | 211 typedef Benchmark INHERITED; |
212 }; | 212 }; |
213 | 213 |
214 class WeakRefCntBench_New : public Benchmark { | 214 class WeakRefCntBench_New : public Benchmark { |
215 public: | 215 public: |
216 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { | 216 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
217 return backend == kNonRendering_Backend; | 217 return backend == kNonRendering_Backend; |
218 } | 218 } |
219 | 219 |
220 protected: | 220 protected: |
221 virtual const char* onGetName() { | 221 virtual const char* onGetName() SK_OVERRIDE { |
222 return "ref_cnt_new_weak"; | 222 return "ref_cnt_new_weak"; |
223 } | 223 } |
224 | 224 |
225 virtual void onDraw(const int loops, SkCanvas*) { | 225 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { |
226 for (int i = 0; i < loops; ++i) { | 226 for (int i = 0; i < loops; ++i) { |
227 SkWeakRefCnt* ref = new SkWeakRefCnt(); | 227 SkWeakRefCnt* ref = new SkWeakRefCnt(); |
228 for (int j = 0; j < M; ++j) { | 228 for (int j = 0; j < M; ++j) { |
229 ref->ref(); | 229 ref->ref(); |
230 ref->unref(); | 230 ref->unref(); |
231 } | 231 } |
232 ref->unref(); | 232 ref->unref(); |
233 } | 233 } |
234 } | 234 } |
235 | 235 |
236 private: | 236 private: |
237 typedef Benchmark INHERITED; | 237 typedef Benchmark INHERITED; |
238 }; | 238 }; |
239 | 239 |
240 /////////////////////////////////////////////////////////////////////////////// | 240 /////////////////////////////////////////////////////////////////////////////// |
241 | 241 |
242 DEF_BENCH( return new AtomicInc32(); ) | 242 DEF_BENCH( return new AtomicInc32(); ) |
243 DEF_BENCH( return new AtomicInc64(); ) | 243 DEF_BENCH( return new AtomicInc64(); ) |
244 | 244 |
245 DEF_BENCH( return new RefCntBench_Stack(); ) | 245 DEF_BENCH( return new RefCntBench_Stack(); ) |
246 DEF_BENCH( return new RefCntBench_Heap(); ) | 246 DEF_BENCH( return new RefCntBench_Heap(); ) |
247 DEF_BENCH( return new RefCntBench_New(); ) | 247 DEF_BENCH( return new RefCntBench_New(); ) |
248 | 248 |
249 DEF_BENCH( return new WeakRefCntBench_Stack(); ) | 249 DEF_BENCH( return new WeakRefCntBench_Stack(); ) |
250 DEF_BENCH( return new WeakRefCntBench_Heap(); ) | 250 DEF_BENCH( return new WeakRefCntBench_Heap(); ) |
251 DEF_BENCH( return new WeakRefCntBench_New(); ) | 251 DEF_BENCH( return new WeakRefCntBench_New(); ) |
OLD | NEW |