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

Side by Side Diff: bench/RefCntBench.cpp

Issue 1037793002: C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: git cl web Created 5 years, 9 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/RectoriBench.cpp ('k') | bench/RegionBench.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 #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"
11 #include "SkWeakRefCnt.h" 11 #include "SkWeakRefCnt.h"
12 12
13 enum { 13 enum {
14 M = 2 14 M = 2
15 }; 15 };
16 16
17 class AtomicInc32 : public Benchmark { 17 class AtomicInc32 : public Benchmark {
18 public: 18 public:
19 AtomicInc32() : fX(0) {} 19 AtomicInc32() : fX(0) {}
20 20
21 bool isSuitableFor(Backend backend) SK_OVERRIDE { 21 bool isSuitableFor(Backend backend) override {
22 return backend == kNonRendering_Backend; 22 return backend == kNonRendering_Backend;
23 } 23 }
24 24
25 protected: 25 protected:
26 virtual const char* onGetName() { 26 virtual const char* onGetName() {
27 return "atomic_inc_32"; 27 return "atomic_inc_32";
28 } 28 }
29 29
30 virtual void onDraw(const int loops, SkCanvas*) { 30 virtual void onDraw(const int loops, SkCanvas*) {
31 for (int i = 0; i < loops; ++i) { 31 for (int i = 0; i < loops; ++i) {
32 sk_atomic_inc(&fX); 32 sk_atomic_inc(&fX);
33 } 33 }
34 } 34 }
35 35
36 private: 36 private:
37 int32_t fX; 37 int32_t fX;
38 typedef Benchmark INHERITED; 38 typedef Benchmark INHERITED;
39 }; 39 };
40 40
41 class AtomicInc64 : public Benchmark { 41 class AtomicInc64 : public Benchmark {
42 public: 42 public:
43 AtomicInc64() : fX(0) {} 43 AtomicInc64() : fX(0) {}
44 44
45 bool isSuitableFor(Backend backend) SK_OVERRIDE { 45 bool isSuitableFor(Backend backend) override {
46 return backend == kNonRendering_Backend; 46 return backend == kNonRendering_Backend;
47 } 47 }
48 48
49 protected: 49 protected:
50 virtual const char* onGetName() { 50 virtual const char* onGetName() {
51 return "atomic_inc_64"; 51 return "atomic_inc_64";
52 } 52 }
53 53
54 virtual void onDraw(const int loops, SkCanvas*) { 54 virtual void onDraw(const int loops, SkCanvas*) {
55 for (int i = 0; i < loops; ++i) { 55 for (int i = 0; i < loops; ++i) {
56 sk_atomic_inc(&fX); 56 sk_atomic_inc(&fX);
57 } 57 }
58 } 58 }
59 59
60 private: 60 private:
61 int64_t fX; 61 int64_t fX;
62 typedef Benchmark INHERITED; 62 typedef Benchmark INHERITED;
63 }; 63 };
64 64
65 class RefCntBench_Stack : public Benchmark { 65 class RefCntBench_Stack : public Benchmark {
66 public: 66 public:
67 bool isSuitableFor(Backend backend) SK_OVERRIDE { 67 bool isSuitableFor(Backend backend) override {
68 return backend == kNonRendering_Backend; 68 return backend == kNonRendering_Backend;
69 } 69 }
70 70
71 protected: 71 protected:
72 virtual const char* onGetName() { 72 virtual const char* onGetName() {
73 return "ref_cnt_stack"; 73 return "ref_cnt_stack";
74 } 74 }
75 75
76 virtual void onDraw(const int loops, SkCanvas*) { 76 virtual void onDraw(const int loops, SkCanvas*) {
77 for (int i = 0; i < loops; ++i) { 77 for (int i = 0; i < loops; ++i) {
(...skipping 15 matching lines...) Expand all
93 93
94 PlacedRefCnt() : SkRefCnt() { } 94 PlacedRefCnt() : SkRefCnt() { }
95 void operator delete(void*) { } 95 void operator delete(void*) { }
96 96
97 private: 97 private:
98 typedef SkRefCnt INHERITED; 98 typedef SkRefCnt INHERITED;
99 }; 99 };
100 100
101 class RefCntBench_Heap : public Benchmark { 101 class RefCntBench_Heap : public Benchmark {
102 public: 102 public:
103 bool isSuitableFor(Backend backend) SK_OVERRIDE { 103 bool isSuitableFor(Backend backend) override {
104 return backend == kNonRendering_Backend; 104 return backend == kNonRendering_Backend;
105 } 105 }
106 106
107 protected: 107 protected:
108 virtual const char* onGetName() { 108 virtual const char* onGetName() {
109 return "ref_cnt_heap"; 109 return "ref_cnt_heap";
110 } 110 }
111 111
112 virtual void onDraw(const int loops, SkCanvas*) { 112 virtual void onDraw(const int loops, SkCanvas*) {
113 char memory[sizeof(PlacedRefCnt)]; 113 char memory[sizeof(PlacedRefCnt)];
114 for (int i = 0; i < loops; ++i) { 114 for (int i = 0; i < loops; ++i) {
115 PlacedRefCnt* ref = new (memory) PlacedRefCnt(); 115 PlacedRefCnt* ref = new (memory) PlacedRefCnt();
116 for (int j = 0; j < M; ++j) { 116 for (int j = 0; j < M; ++j) {
117 ref->ref(); 117 ref->ref();
118 ref->unref(); 118 ref->unref();
119 } 119 }
120 ref->unref(); 120 ref->unref();
121 } 121 }
122 } 122 }
123 123
124 private: 124 private:
125 typedef Benchmark INHERITED; 125 typedef Benchmark INHERITED;
126 }; 126 };
127 127
128 class RefCntBench_New : public Benchmark { 128 class RefCntBench_New : public Benchmark {
129 public: 129 public:
130 bool isSuitableFor(Backend backend) SK_OVERRIDE { 130 bool isSuitableFor(Backend backend) override {
131 return backend == kNonRendering_Backend; 131 return backend == kNonRendering_Backend;
132 } 132 }
133 133
134 protected: 134 protected:
135 virtual const char* onGetName() { 135 virtual const char* onGetName() {
136 return "ref_cnt_new"; 136 return "ref_cnt_new";
137 } 137 }
138 138
139 virtual void onDraw(const int loops, SkCanvas*) { 139 virtual void onDraw(const int loops, SkCanvas*) {
140 for (int i = 0; i < loops; ++i) { 140 for (int i = 0; i < loops; ++i) {
141 SkRefCnt* ref = new SkRefCnt(); 141 SkRefCnt* ref = new SkRefCnt();
142 for (int j = 0; j < M; ++j) { 142 for (int j = 0; j < M; ++j) {
143 ref->ref(); 143 ref->ref();
144 ref->unref(); 144 ref->unref();
145 } 145 }
146 ref->unref(); 146 ref->unref();
147 } 147 }
148 } 148 }
149 149
150 private: 150 private:
151 typedef Benchmark INHERITED; 151 typedef Benchmark INHERITED;
152 }; 152 };
153 153
154 /////////////////////////////////////////////////////////////////////////////// 154 ///////////////////////////////////////////////////////////////////////////////
155 155
156 class WeakRefCntBench_Stack : public Benchmark { 156 class WeakRefCntBench_Stack : public Benchmark {
157 public: 157 public:
158 bool isSuitableFor(Backend backend) SK_OVERRIDE { 158 bool isSuitableFor(Backend backend) override {
159 return backend == kNonRendering_Backend; 159 return backend == kNonRendering_Backend;
160 } 160 }
161 161
162 protected: 162 protected:
163 virtual const char* onGetName() { 163 virtual const char* onGetName() {
164 return "ref_cnt_stack_weak"; 164 return "ref_cnt_stack_weak";
165 } 165 }
166 166
167 virtual void onDraw(const int loops, SkCanvas*) { 167 virtual void onDraw(const int loops, SkCanvas*) {
168 for (int i = 0; i < loops; ++i) { 168 for (int i = 0; i < loops; ++i) {
(...skipping 10 matching lines...) Expand all
179 }; 179 };
180 180
181 class PlacedWeakRefCnt : public SkWeakRefCnt { 181 class PlacedWeakRefCnt : public SkWeakRefCnt {
182 public: 182 public:
183 PlacedWeakRefCnt() : SkWeakRefCnt() { } 183 PlacedWeakRefCnt() : SkWeakRefCnt() { }
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 bool isSuitableFor(Backend backend) SK_OVERRIDE { 189 bool isSuitableFor(Backend backend) override {
190 return backend == kNonRendering_Backend; 190 return backend == kNonRendering_Backend;
191 } 191 }
192 192
193 protected: 193 protected:
194 const char* onGetName() SK_OVERRIDE { 194 const char* onGetName() override {
195 return "ref_cnt_heap_weak"; 195 return "ref_cnt_heap_weak";
196 } 196 }
197 197
198 void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { 198 void onDraw(const int loops, SkCanvas*) 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 bool isSuitableFor(Backend backend) SK_OVERRIDE { 216 bool isSuitableFor(Backend backend) override {
217 return backend == kNonRendering_Backend; 217 return backend == kNonRendering_Backend;
218 } 218 }
219 219
220 protected: 220 protected:
221 const char* onGetName() SK_OVERRIDE { 221 const char* onGetName() override {
222 return "ref_cnt_new_weak"; 222 return "ref_cnt_new_weak";
223 } 223 }
224 224
225 void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { 225 void onDraw(const int loops, SkCanvas*) 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(); )
OLDNEW
« no previous file with comments | « bench/RectoriBench.cpp ('k') | bench/RegionBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698