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 |
(...skipping 17 matching lines...) Expand all Loading... |
28 }; | 28 }; |
29 GrMemoryPool A::gPool(10 * (1 << 10), 10 * (1 << 10)); | 29 GrMemoryPool A::gPool(10 * (1 << 10), 10 * (1 << 10)); |
30 } | 30 } |
31 | 31 |
32 | 32 |
33 /** | 33 /** |
34 * This benchmark creates and deletes objects in stack order | 34 * This benchmark creates and deletes objects in stack order |
35 */ | 35 */ |
36 class GrMemoryPoolBenchStack : public SkBenchmark { | 36 class GrMemoryPoolBenchStack : public SkBenchmark { |
37 public: | 37 public: |
38 GrMemoryPoolBenchStack(void* param) : INHERITED(param) { | 38 GrMemoryPoolBenchStack() { |
39 fIsRendering = false; | 39 fIsRendering = false; |
40 } | 40 } |
41 protected: | 41 protected: |
42 virtual const char* onGetName() { | 42 virtual const char* onGetName() { |
43 return "grmemorypool_stack"; | 43 return "grmemorypool_stack"; |
44 } | 44 } |
45 | 45 |
46 virtual void onDraw(SkCanvas*) { | 46 virtual void onDraw(SkCanvas*) { |
47 SkRandom r; | 47 SkRandom r; |
48 enum { | 48 enum { |
(...skipping 30 matching lines...) Expand all Loading... |
79 | 79 |
80 private: | 80 private: |
81 typedef SkBenchmark INHERITED; | 81 typedef SkBenchmark INHERITED; |
82 }; | 82 }; |
83 | 83 |
84 /** | 84 /** |
85 * This benchmark creates objects and deletes them in random order | 85 * This benchmark creates objects and deletes them in random order |
86 */ | 86 */ |
87 class GrMemoryPoolBenchRandom : public SkBenchmark { | 87 class GrMemoryPoolBenchRandom : public SkBenchmark { |
88 public: | 88 public: |
89 GrMemoryPoolBenchRandom(void* param) : INHERITED(param) { | 89 GrMemoryPoolBenchRandom() { |
90 fIsRendering = false; | 90 fIsRendering = false; |
91 } | 91 } |
92 protected: | 92 protected: |
93 virtual const char* onGetName() { | 93 virtual const char* onGetName() { |
94 return "grmemorypool_random"; | 94 return "grmemorypool_random"; |
95 } | 95 } |
96 | 96 |
97 virtual void onDraw(SkCanvas*) { | 97 virtual void onDraw(SkCanvas*) { |
98 SkRandom r; | 98 SkRandom r; |
99 enum { | 99 enum { |
(...skipping 16 matching lines...) Expand all Loading... |
116 }; | 116 }; |
117 | 117 |
118 /** | 118 /** |
119 * This benchmark creates objects and deletes them in queue order | 119 * This benchmark creates objects and deletes them in queue order |
120 */ | 120 */ |
121 class GrMemoryPoolBenchQueue : public SkBenchmark { | 121 class GrMemoryPoolBenchQueue : public SkBenchmark { |
122 enum { | 122 enum { |
123 M = 4 * (1 << 10), | 123 M = 4 * (1 << 10), |
124 }; | 124 }; |
125 public: | 125 public: |
126 GrMemoryPoolBenchQueue(void* param) : INHERITED(param) { | 126 GrMemoryPoolBenchQueue() { |
127 fIsRendering = false; | 127 fIsRendering = false; |
128 } | 128 } |
129 protected: | 129 protected: |
130 virtual const char* onGetName() { | 130 virtual const char* onGetName() { |
131 return "grmemorypool_queue"; | 131 return "grmemorypool_queue"; |
132 } | 132 } |
133 | 133 |
134 virtual void onDraw(SkCanvas*) { | 134 virtual void onDraw(SkCanvas*) { |
135 SkRandom r; | 135 SkRandom r; |
136 A* objects[M]; | 136 A* objects[M]; |
137 for (int i = 0; i < this->getLoops(); i++) { | 137 for (int i = 0; i < this->getLoops(); i++) { |
138 uint32_t count = r.nextRangeU(0, M-1); | 138 uint32_t count = r.nextRangeU(0, M-1); |
139 for (uint32_t i = 0; i < count; i++) { | 139 for (uint32_t i = 0; i < count; i++) { |
140 objects[i] = new A; | 140 objects[i] = new A; |
141 } | 141 } |
142 for (uint32_t i = 0; i < count; i++) { | 142 for (uint32_t i = 0; i < count; i++) { |
143 delete objects[i]; | 143 delete objects[i]; |
144 } | 144 } |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
148 private: | 148 private: |
149 typedef SkBenchmark INHERITED; | 149 typedef SkBenchmark INHERITED; |
150 }; | 150 }; |
151 | 151 |
152 /////////////////////////////////////////////////////////////////////////////// | 152 /////////////////////////////////////////////////////////////////////////////// |
153 | 153 |
154 static SkBenchmark* Fact1(void* p) { return new GrMemoryPoolBenchStack(p); } | 154 DEF_BENCH( return new GrMemoryPoolBenchStack(); ) |
155 static SkBenchmark* Fact2(void* p) { return new GrMemoryPoolBenchRandom(p); } | 155 DEF_BENCH( return new GrMemoryPoolBenchRandom(); ) |
156 static SkBenchmark* Fact3(void* p) { return new GrMemoryPoolBenchQueue(p); } | 156 DEF_BENCH( return new GrMemoryPoolBenchQueue(); ) |
157 | |
158 static BenchRegistry gReg01(Fact1); | |
159 static BenchRegistry gReg02(Fact2); | |
160 static BenchRegistry gReg03(Fact3); | |
161 | |
162 #endif | 157 #endif |
OLD | NEW |