| 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 // This tests a Gr class | 8 // This tests a Gr class |
| 9 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
| 10 | 10 |
| 11 #include "GrMemoryPool.h" | 11 #include "GrMemoryPool.h" |
| 12 #include "SkBenchmark.h" | 12 #include "SkBenchmark.h" |
| 13 #include "SkRandom.h" | 13 #include "SkRandom.h" |
| 14 #include "SkTDArray.h" | 14 #include "SkTDArray.h" |
| 15 #include "SkTemplates.h" | 15 #include "SkTemplates.h" |
| 16 | 16 |
| 17 // change this to 0 to compare GrMemoryPool to default new / delete | 17 // change this to 0 to compare GrMemoryPool to default new / delete |
| 18 #define OVERRIDE_NEW 1 | 18 #define OVERRIDE_NEW 1 |
| 19 | 19 |
| 20 namespace { | |
| 21 struct A { | 20 struct A { |
| 22 int gStuff[10]; | 21 int gStuff[10]; |
| 23 #if OVERRIDE_NEW | 22 #if OVERRIDE_NEW |
| 24 void* operator new (size_t size) { return gPool.allocate(size); } | 23 void* operator new (size_t size) { return gPool.allocate(size); } |
| 25 void operator delete (void* mem) { if (mem) { return gPool.release(mem); } } | 24 void operator delete (void* mem) { if (mem) { return gPool.release(mem); } } |
| 26 #endif | 25 #endif |
| 27 static GrMemoryPool gPool; | 26 static GrMemoryPool gPool; |
| 28 }; | 27 }; |
| 29 GrMemoryPool A::gPool(10 * (1 << 10), 10 * (1 << 10)); | 28 GrMemoryPool A::gPool(10 * (1 << 10), 10 * (1 << 10)); |
| 30 } | |
| 31 | |
| 32 | 29 |
| 33 /** | 30 /** |
| 34 * This benchmark creates and deletes objects in stack order | 31 * This benchmark creates and deletes objects in stack order |
| 35 */ | 32 */ |
| 36 class GrMemoryPoolBenchStack : public SkBenchmark { | 33 class GrMemoryPoolBenchStack : public SkBenchmark { |
| 37 public: | 34 public: |
| 38 GrMemoryPoolBenchStack() { | 35 GrMemoryPoolBenchStack() { |
| 39 fIsRendering = false; | 36 fIsRendering = false; |
| 40 } | 37 } |
| 41 protected: | 38 protected: |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 144 |
| 148 private: | 145 private: |
| 149 typedef SkBenchmark INHERITED; | 146 typedef SkBenchmark INHERITED; |
| 150 }; | 147 }; |
| 151 | 148 |
| 152 /////////////////////////////////////////////////////////////////////////////// | 149 /////////////////////////////////////////////////////////////////////////////// |
| 153 | 150 |
| 154 DEF_BENCH( return new GrMemoryPoolBenchStack(); ) | 151 DEF_BENCH( return new GrMemoryPoolBenchStack(); ) |
| 155 DEF_BENCH( return new GrMemoryPoolBenchRandom(); ) | 152 DEF_BENCH( return new GrMemoryPoolBenchRandom(); ) |
| 156 DEF_BENCH( return new GrMemoryPoolBenchQueue(); ) | 153 DEF_BENCH( return new GrMemoryPoolBenchQueue(); ) |
| 154 |
| 157 #endif | 155 #endif |
| OLD | NEW |