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

Side by Side Diff: bench/MathBench.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/MagnifierBench.cpp ('k') | bench/Matrix44Bench.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 #include "Benchmark.h" 1 #include "Benchmark.h"
2 #include "SkColorPriv.h" 2 #include "SkColorPriv.h"
3 #include "SkMatrix.h" 3 #include "SkMatrix.h"
4 #include "SkPaint.h" 4 #include "SkPaint.h"
5 #include "SkRandom.h" 5 #include "SkRandom.h"
6 #include "SkString.h" 6 #include "SkString.h"
7 7
8 static float sk_fsel(float pred, float result_ge, float result_lt) { 8 static float sk_fsel(float pred, float result_ge, float result_lt) {
9 return pred >= 0 ? result_ge : result_lt; 9 return pred >= 0 ? result_ge : result_lt;
10 } 10 }
(...skipping 13 matching lines...) Expand all
24 public: 24 public:
25 MathBench(const char name[]) { 25 MathBench(const char name[]) {
26 fName.printf("math_%s", name); 26 fName.printf("math_%s", name);
27 27
28 SkRandom rand; 28 SkRandom rand;
29 for (int i = 0; i < kBuffer; ++i) { 29 for (int i = 0; i < kBuffer; ++i) {
30 fSrc[i] = rand.nextSScalar1(); 30 fSrc[i] = rand.nextSScalar1();
31 } 31 }
32 } 32 }
33 33
34 bool isSuitableFor(Backend backend) SK_OVERRIDE { 34 bool isSuitableFor(Backend backend) override {
35 return backend == kNonRendering_Backend; 35 return backend == kNonRendering_Backend;
36 } 36 }
37 37
38 virtual void performTest(float* SK_RESTRICT dst, 38 virtual void performTest(float* SK_RESTRICT dst,
39 const float* SK_RESTRICT src, 39 const float* SK_RESTRICT src,
40 int count) = 0; 40 int count) = 0;
41 41
42 protected: 42 protected:
43 virtual int mulLoopCount() const { return 1; } 43 virtual int mulLoopCount() const { return 1; }
44 44
(...skipping 16 matching lines...) Expand all
61 public: 61 public:
62 MathBenchU32(const char name[]) : INHERITED(name) {} 62 MathBenchU32(const char name[]) : INHERITED(name) {}
63 63
64 protected: 64 protected:
65 virtual void performITest(uint32_t* SK_RESTRICT dst, 65 virtual void performITest(uint32_t* SK_RESTRICT dst,
66 const uint32_t* SK_RESTRICT src, 66 const uint32_t* SK_RESTRICT src,
67 int count) = 0; 67 int count) = 0;
68 68
69 virtual void performTest(float* SK_RESTRICT dst, 69 virtual void performTest(float* SK_RESTRICT dst,
70 const float* SK_RESTRICT src, 70 const float* SK_RESTRICT src,
71 int count) SK_OVERRIDE { 71 int count) override {
72 uint32_t* d = SkTCast<uint32_t*>(dst); 72 uint32_t* d = SkTCast<uint32_t*>(dst);
73 const uint32_t* s = SkTCast<const uint32_t*>(src); 73 const uint32_t* s = SkTCast<const uint32_t*>(src);
74 this->performITest(d, s, count); 74 this->performITest(d, s, count);
75 } 75 }
76 private: 76 private:
77 typedef MathBench INHERITED; 77 typedef MathBench INHERITED;
78 }; 78 };
79 79
80 /////////////////////////////////////////////////////////////////////////////// 80 ///////////////////////////////////////////////////////////////////////////////
81 81
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 tmp *= alpha; 159 tmp *= alpha;
160 return (uint32_t) (((tmp >> 8) & mask) | ((tmp >> 32) & ~mask)); 160 return (uint32_t) (((tmp >> 8) & mask) | ((tmp >> 32) & ~mask));
161 } 161 }
162 162
163 class QMul64Bench : public MathBenchU32 { 163 class QMul64Bench : public MathBenchU32 {
164 public: 164 public:
165 QMul64Bench() : INHERITED("qmul64") {} 165 QMul64Bench() : INHERITED("qmul64") {}
166 protected: 166 protected:
167 virtual void performITest(uint32_t* SK_RESTRICT dst, 167 virtual void performITest(uint32_t* SK_RESTRICT dst,
168 const uint32_t* SK_RESTRICT src, 168 const uint32_t* SK_RESTRICT src,
169 int count) SK_OVERRIDE { 169 int count) override {
170 for (int i = 0; i < count; ++i) { 170 for (int i = 0; i < count; ++i) {
171 dst[i] = QMul64(src[i], (uint8_t)i); 171 dst[i] = QMul64(src[i], (uint8_t)i);
172 } 172 }
173 } 173 }
174 private: 174 private:
175 typedef MathBenchU32 INHERITED; 175 typedef MathBenchU32 INHERITED;
176 }; 176 };
177 177
178 class QMul32Bench : public MathBenchU32 { 178 class QMul32Bench : public MathBenchU32 {
179 public: 179 public:
180 QMul32Bench() : INHERITED("qmul32") {} 180 QMul32Bench() : INHERITED("qmul32") {}
181 protected: 181 protected:
182 virtual void performITest(uint32_t* SK_RESTRICT dst, 182 virtual void performITest(uint32_t* SK_RESTRICT dst,
183 const uint32_t* SK_RESTRICT src, 183 const uint32_t* SK_RESTRICT src,
184 int count) SK_OVERRIDE { 184 int count) override {
185 for (int i = 0; i < count; ++i) { 185 for (int i = 0; i < count; ++i) {
186 dst[i] = SkAlphaMulQ(src[i], (uint8_t)i); 186 dst[i] = SkAlphaMulQ(src[i], (uint8_t)i);
187 } 187 }
188 } 188 }
189 private: 189 private:
190 typedef MathBenchU32 INHERITED; 190 typedef MathBenchU32 INHERITED;
191 }; 191 };
192 192
193 /////////////////////////////////////////////////////////////////////////////// 193 ///////////////////////////////////////////////////////////////////////////////
194 194
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 278
279 if (index < 0) { 279 if (index < 0) {
280 fProc = NULL; 280 fProc = NULL;
281 fName = "isfinite_rect"; 281 fName = "isfinite_rect";
282 } else { 282 } else {
283 fProc = gRec[index].fProc; 283 fProc = gRec[index].fProc;
284 fName = gRec[index].fName; 284 fName = gRec[index].fName;
285 } 285 }
286 } 286 }
287 287
288 bool isSuitableFor(Backend backend) SK_OVERRIDE { 288 bool isSuitableFor(Backend backend) override {
289 return backend == kNonRendering_Backend; 289 return backend == kNonRendering_Backend;
290 } 290 }
291 291
292 protected: 292 protected:
293 virtual void onDraw(const int loops, SkCanvas*) { 293 virtual void onDraw(const int loops, SkCanvas*) {
294 IsFiniteProc proc = fProc; 294 IsFiniteProc proc = fProc;
295 const float* data = fData; 295 const float* data = fData;
296 // do this so the compiler won't throw away the function call 296 // do this so the compiler won't throw away the function call
297 int counter = 0; 297 int counter = 0;
298 298
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 fData[i] = rand.nextSScalar1(); 346 fData[i] = rand.nextSScalar1();
347 } 347 }
348 348
349 if (fast) { 349 if (fast) {
350 fName = "floor_fast"; 350 fName = "floor_fast";
351 } else { 351 } else {
352 fName = "floor_std"; 352 fName = "floor_std";
353 } 353 }
354 } 354 }
355 355
356 bool isSuitableFor(Backend backend) SK_OVERRIDE { 356 bool isSuitableFor(Backend backend) override {
357 return backend == kNonRendering_Backend; 357 return backend == kNonRendering_Backend;
358 } 358 }
359 359
360 virtual void process(float) {} 360 virtual void process(float) {}
361 361
362 protected: 362 protected:
363 virtual void onDraw(const int loops, SkCanvas*) { 363 virtual void onDraw(const int loops, SkCanvas*) {
364 SkRandom rand; 364 SkRandom rand;
365 float accum = 0; 365 float accum = 0;
366 const float* data = fData; 366 const float* data = fData;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 fData[i] = rand.nextU(); 407 fData[i] = rand.nextU();
408 } 408 }
409 409
410 if (fUsePortable) { 410 if (fUsePortable) {
411 fName = "clz_portable"; 411 fName = "clz_portable";
412 } else { 412 } else {
413 fName = "clz_intrinsic"; 413 fName = "clz_intrinsic";
414 } 414 }
415 } 415 }
416 416
417 bool isSuitableFor(Backend backend) SK_OVERRIDE { 417 bool isSuitableFor(Backend backend) override {
418 return backend == kNonRendering_Backend; 418 return backend == kNonRendering_Backend;
419 } 419 }
420 420
421 // just so the compiler doesn't remove our loops 421 // just so the compiler doesn't remove our loops
422 virtual void process(int) {} 422 virtual void process(int) {}
423 423
424 protected: 424 protected:
425 virtual void onDraw(const int loops, SkCanvas*) { 425 virtual void onDraw(const int loops, SkCanvas*) {
426 int accum = 0; 426 int accum = 0;
427 427
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 public: 463 public:
464 NormalizeBench() { 464 NormalizeBench() {
465 SkRandom rand; 465 SkRandom rand;
466 for (int i = 0; i < ARRAY; ++i) { 466 for (int i = 0; i < ARRAY; ++i) {
467 fVec[i].set(rand.nextSScalar1(), rand.nextSScalar1()); 467 fVec[i].set(rand.nextSScalar1(), rand.nextSScalar1());
468 } 468 }
469 469
470 fName = "point_normalize"; 470 fName = "point_normalize";
471 } 471 }
472 472
473 bool isSuitableFor(Backend backend) SK_OVERRIDE { 473 bool isSuitableFor(Backend backend) override {
474 return backend == kNonRendering_Backend; 474 return backend == kNonRendering_Backend;
475 } 475 }
476 476
477 // just so the compiler doesn't remove our loops 477 // just so the compiler doesn't remove our loops
478 virtual void process(int) {} 478 virtual void process(int) {}
479 479
480 protected: 480 protected:
481 virtual void onDraw(const int loops, SkCanvas*) { 481 virtual void onDraw(const int loops, SkCanvas*) {
482 int accum = 0; 482 int accum = 0;
483 483
(...skipping 26 matching lines...) Expand all
510 public: 510 public:
511 511
512 FixedMathBench() { 512 FixedMathBench() {
513 SkRandom rand; 513 SkRandom rand;
514 for (int i = 0; i < N; ++i) { 514 for (int i = 0; i < N; ++i) {
515 fData[i] = rand.nextSScalar1(); 515 fData[i] = rand.nextSScalar1();
516 } 516 }
517 517
518 } 518 }
519 519
520 bool isSuitableFor(Backend backend) SK_OVERRIDE { 520 bool isSuitableFor(Backend backend) override {
521 return backend == kNonRendering_Backend; 521 return backend == kNonRendering_Backend;
522 } 522 }
523 523
524 protected: 524 protected:
525 virtual void onDraw(const int loops, SkCanvas*) { 525 virtual void onDraw(const int loops, SkCanvas*) {
526 for (int j = 0; j < loops; ++j) { 526 for (int j = 0; j < loops; ++j) {
527 for (int i = 0; i < N - 4; ++i) { 527 for (int i = 0; i < N - 4; ++i) {
528 fResult[i] = SkFloatToFixed(fData[i]); 528 fResult[i] = SkFloatToFixed(fData[i]);
529 } 529 }
530 } 530 }
(...skipping 15 matching lines...) Expand all
546 /////////////////////////////////////////////////////////////////////////////// 546 ///////////////////////////////////////////////////////////////////////////////
547 547
548 template <typename T> 548 template <typename T>
549 class DivModBench : public Benchmark { 549 class DivModBench : public Benchmark {
550 SkString fName; 550 SkString fName;
551 public: 551 public:
552 explicit DivModBench(const char* name) { 552 explicit DivModBench(const char* name) {
553 fName.printf("divmod_%s", name); 553 fName.printf("divmod_%s", name);
554 } 554 }
555 555
556 bool isSuitableFor(Backend backend) SK_OVERRIDE { 556 bool isSuitableFor(Backend backend) override {
557 return backend == kNonRendering_Backend; 557 return backend == kNonRendering_Backend;
558 } 558 }
559 559
560 protected: 560 protected:
561 virtual const char* onGetName() { 561 virtual const char* onGetName() {
562 return fName.c_str(); 562 return fName.c_str();
563 } 563 }
564 564
565 virtual void onDraw(const int loops, SkCanvas*) { 565 virtual void onDraw(const int loops, SkCanvas*) {
566 volatile T a = 0, b = 0; 566 volatile T a = 0, b = 0;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 602
603 DEF_BENCH( return new FloorBench(false); ) 603 DEF_BENCH( return new FloorBench(false); )
604 DEF_BENCH( return new FloorBench(true); ) 604 DEF_BENCH( return new FloorBench(true); )
605 605
606 DEF_BENCH( return new CLZBench(false); ) 606 DEF_BENCH( return new CLZBench(false); )
607 DEF_BENCH( return new CLZBench(true); ) 607 DEF_BENCH( return new CLZBench(true); )
608 608
609 DEF_BENCH( return new NormalizeBench(); ) 609 DEF_BENCH( return new NormalizeBench(); )
610 610
611 DEF_BENCH( return new FixedMathBench(); ) 611 DEF_BENCH( return new FixedMathBench(); )
OLDNEW
« no previous file with comments | « bench/MagnifierBench.cpp ('k') | bench/Matrix44Bench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698