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

Side by Side Diff: bench/RefCntBench.cpp

Issue 1232463006: Fix up -Winconsistent-missing-override (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: llvm_coverage_build Created 5 years, 5 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/PictureNestingBench.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 "SkAtomics.h" 9 #include "SkAtomics.h"
10 #include "SkRefCnt.h" 10 #include "SkRefCnt.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) 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 const char* onGetName() override {
27 return "atomic_inc_32"; 27 return "atomic_inc_32";
28 } 28 }
29 29
30 virtual void onDraw(const int loops, SkCanvas*) { 30 void onDraw(const int loops, SkCanvas*) override {
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) 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 const char* onGetName() override {
51 return "atomic_inc_64"; 51 return "atomic_inc_64";
52 } 52 }
53 53
54 virtual void onDraw(const int loops, SkCanvas*) { 54 void onDraw(const int loops, SkCanvas*) override {
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) 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 const char* onGetName() override {
73 return "ref_cnt_stack"; 73 return "ref_cnt_stack";
74 } 74 }
75 75
76 virtual void onDraw(const int loops, SkCanvas*) { 76 void onDraw(const int loops, SkCanvas*) override {
77 for (int i = 0; i < loops; ++i) { 77 for (int i = 0; i < loops; ++i) {
78 SkRefCnt ref; 78 SkRefCnt ref;
79 for (int j = 0; j < M; ++j) { 79 for (int j = 0; j < M; ++j) {
80 ref.ref(); 80 ref.ref();
81 ref.unref(); 81 ref.unref();
82 } 82 }
83 } 83 }
84 } 84 }
85 85
86 private: 86 private:
87 typedef Benchmark INHERITED; 87 typedef Benchmark INHERITED;
88 }; 88 };
89 89
90 class PlacedRefCnt : public SkRefCnt { 90 class PlacedRefCnt : public SkRefCnt {
91 public: 91 public:
92 PlacedRefCnt() : SkRefCnt() { } 92 PlacedRefCnt() : SkRefCnt() { }
93 void operator delete(void*) { } 93 void operator delete(void*) { }
94 94
95 private: 95 private:
96 typedef SkRefCnt INHERITED; 96 typedef SkRefCnt INHERITED;
97 }; 97 };
98 98
99 class RefCntBench_Heap : public Benchmark { 99 class RefCntBench_Heap : public Benchmark {
100 public: 100 public:
101 bool isSuitableFor(Backend backend) override { 101 bool isSuitableFor(Backend backend) override {
102 return backend == kNonRendering_Backend; 102 return backend == kNonRendering_Backend;
103 } 103 }
104 104
105 protected: 105 protected:
106 virtual const char* onGetName() { 106 const char* onGetName() override {
107 return "ref_cnt_heap"; 107 return "ref_cnt_heap";
108 } 108 }
109 109
110 virtual void onDraw(const int loops, SkCanvas*) { 110 void onDraw(const int loops, SkCanvas*) override {
111 char memory[sizeof(PlacedRefCnt)]; 111 char memory[sizeof(PlacedRefCnt)];
112 for (int i = 0; i < loops; ++i) { 112 for (int i = 0; i < loops; ++i) {
113 PlacedRefCnt* ref = new (memory) PlacedRefCnt(); 113 PlacedRefCnt* ref = new (memory) PlacedRefCnt();
114 for (int j = 0; j < M; ++j) { 114 for (int j = 0; j < M; ++j) {
115 ref->ref(); 115 ref->ref();
116 ref->unref(); 116 ref->unref();
117 } 117 }
118 ref->unref(); 118 ref->unref();
119 } 119 }
120 } 120 }
121 121
122 private: 122 private:
123 typedef Benchmark INHERITED; 123 typedef Benchmark INHERITED;
124 }; 124 };
125 125
126 class RefCntBench_New : public Benchmark { 126 class RefCntBench_New : public Benchmark {
127 public: 127 public:
128 bool isSuitableFor(Backend backend) override { 128 bool isSuitableFor(Backend backend) override {
129 return backend == kNonRendering_Backend; 129 return backend == kNonRendering_Backend;
130 } 130 }
131 131
132 protected: 132 protected:
133 virtual const char* onGetName() { 133 const char* onGetName() override {
134 return "ref_cnt_new"; 134 return "ref_cnt_new";
135 } 135 }
136 136
137 virtual void onDraw(const int loops, SkCanvas*) { 137 void onDraw(const int loops, SkCanvas*) override {
138 for (int i = 0; i < loops; ++i) { 138 for (int i = 0; i < loops; ++i) {
139 SkRefCnt* ref = new SkRefCnt(); 139 SkRefCnt* ref = new SkRefCnt();
140 for (int j = 0; j < M; ++j) { 140 for (int j = 0; j < M; ++j) {
141 ref->ref(); 141 ref->ref();
142 ref->unref(); 142 ref->unref();
143 } 143 }
144 ref->unref(); 144 ref->unref();
145 } 145 }
146 } 146 }
147 147
148 private: 148 private:
149 typedef Benchmark INHERITED; 149 typedef Benchmark INHERITED;
150 }; 150 };
151 151
152 /////////////////////////////////////////////////////////////////////////////// 152 ///////////////////////////////////////////////////////////////////////////////
153 153
154 class WeakRefCntBench_Stack : public Benchmark { 154 class WeakRefCntBench_Stack : public Benchmark {
155 public: 155 public:
156 bool isSuitableFor(Backend backend) override { 156 bool isSuitableFor(Backend backend) override {
157 return backend == kNonRendering_Backend; 157 return backend == kNonRendering_Backend;
158 } 158 }
159 159
160 protected: 160 protected:
161 virtual const char* onGetName() { 161 const char* onGetName() override {
162 return "ref_cnt_stack_weak"; 162 return "ref_cnt_stack_weak";
163 } 163 }
164 164
165 virtual void onDraw(const int loops, SkCanvas*) { 165 void onDraw(const int loops, SkCanvas*) override {
166 for (int i = 0; i < loops; ++i) { 166 for (int i = 0; i < loops; ++i) {
167 SkWeakRefCnt ref; 167 SkWeakRefCnt ref;
168 for (int j = 0; j < M; ++j) { 168 for (int j = 0; j < M; ++j) {
169 ref.ref(); 169 ref.ref();
170 ref.unref(); 170 ref.unref();
171 } 171 }
172 } 172 }
173 } 173 }
174 174
175 private: 175 private:
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 DEF_BENCH( return new AtomicInc32(); ) 240 DEF_BENCH( return new AtomicInc32(); )
241 DEF_BENCH( return new AtomicInc64(); ) 241 DEF_BENCH( return new AtomicInc64(); )
242 242
243 DEF_BENCH( return new RefCntBench_Stack(); ) 243 DEF_BENCH( return new RefCntBench_Stack(); )
244 DEF_BENCH( return new RefCntBench_Heap(); ) 244 DEF_BENCH( return new RefCntBench_Heap(); )
245 DEF_BENCH( return new RefCntBench_New(); ) 245 DEF_BENCH( return new RefCntBench_New(); )
246 246
247 DEF_BENCH( return new WeakRefCntBench_Stack(); ) 247 DEF_BENCH( return new WeakRefCntBench_Stack(); )
248 DEF_BENCH( return new WeakRefCntBench_Heap(); ) 248 DEF_BENCH( return new WeakRefCntBench_Heap(); )
249 DEF_BENCH( return new WeakRefCntBench_New(); ) 249 DEF_BENCH( return new WeakRefCntBench_New(); )
OLDNEW
« no previous file with comments | « bench/PictureNestingBench.cpp ('k') | bench/RegionBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698