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

Side by Side Diff: bench/MathBench.cpp

Issue 1379923005: Remove const from `const int loops`. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: n too Created 5 years, 2 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 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 #include "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkMatrix.h" 10 #include "SkMatrix.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 const float* SK_RESTRICT src, 46 const float* SK_RESTRICT src,
47 int count) = 0; 47 int count) = 0;
48 48
49 protected: 49 protected:
50 virtual int mulLoopCount() const { return 1; } 50 virtual int mulLoopCount() const { return 1; }
51 51
52 const char* onGetName() override { 52 const char* onGetName() override {
53 return fName.c_str(); 53 return fName.c_str();
54 } 54 }
55 55
56 void onDraw(const int loops, SkCanvas*) override { 56 void onDraw(int loops, SkCanvas*) override {
57 int n = loops * this->mulLoopCount(); 57 int n = loops * this->mulLoopCount();
58 for (int i = 0; i < n; i++) { 58 for (int i = 0; i < n; i++) {
59 this->performTest(fDst, fSrc, kBuffer); 59 this->performTest(fDst, fSrc, kBuffer);
60 } 60 }
61 } 61 }
62 62
63 private: 63 private:
64 typedef Benchmark INHERITED; 64 typedef Benchmark INHERITED;
65 }; 65 };
66 66
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 fProc = gRec[index].fProc; 280 fProc = gRec[index].fProc;
281 fName = gRec[index].fName; 281 fName = gRec[index].fName;
282 } 282 }
283 } 283 }
284 284
285 bool isSuitableFor(Backend backend) override { 285 bool isSuitableFor(Backend backend) override {
286 return backend == kNonRendering_Backend; 286 return backend == kNonRendering_Backend;
287 } 287 }
288 288
289 protected: 289 protected:
290 void onDraw(const int loops, SkCanvas*) override { 290 void onDraw(int loops, SkCanvas*) override {
291 IsFiniteProc proc = fProc; 291 IsFiniteProc proc = fProc;
292 const float* data = fData; 292 const float* data = fData;
293 // do this so the compiler won't throw away the function call 293 // do this so the compiler won't throw away the function call
294 int counter = 0; 294 int counter = 0;
295 295
296 if (proc) { 296 if (proc) {
297 for (int j = 0; j < loops; ++j) { 297 for (int j = 0; j < loops; ++j) {
298 for (int i = 0; i < N - 4; ++i) { 298 for (int i = 0; i < N - 4; ++i) {
299 counter += proc(&data[i]); 299 counter += proc(&data[i]);
300 } 300 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 350 }
351 } 351 }
352 352
353 bool isSuitableFor(Backend backend) override { 353 bool isSuitableFor(Backend backend) override {
354 return backend == kNonRendering_Backend; 354 return backend == kNonRendering_Backend;
355 } 355 }
356 356
357 virtual void process(float) {} 357 virtual void process(float) {}
358 358
359 protected: 359 protected:
360 void onDraw(const int loops, SkCanvas*) override { 360 void onDraw(int loops, SkCanvas*) override {
361 SkRandom rand; 361 SkRandom rand;
362 float accum = 0; 362 float accum = 0;
363 const float* data = fData; 363 const float* data = fData;
364 364
365 if (fFast) { 365 if (fFast) {
366 for (int j = 0; j < loops; ++j) { 366 for (int j = 0; j < loops; ++j) {
367 for (int i = 0; i < ARRAY; ++i) { 367 for (int i = 0; i < ARRAY; ++i) {
368 accum += fast_floor(data[i]); 368 accum += fast_floor(data[i]);
369 } 369 }
370 this->process(accum); 370 this->process(accum);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 } 412 }
413 413
414 bool isSuitableFor(Backend backend) override { 414 bool isSuitableFor(Backend backend) override {
415 return backend == kNonRendering_Backend; 415 return backend == kNonRendering_Backend;
416 } 416 }
417 417
418 // just so the compiler doesn't remove our loops 418 // just so the compiler doesn't remove our loops
419 virtual void process(int) {} 419 virtual void process(int) {}
420 420
421 protected: 421 protected:
422 void onDraw(const int loops, SkCanvas*) override { 422 void onDraw(int loops, SkCanvas*) override {
423 int accum = 0; 423 int accum = 0;
424 424
425 if (fUsePortable) { 425 if (fUsePortable) {
426 for (int j = 0; j < loops; ++j) { 426 for (int j = 0; j < loops; ++j) {
427 for (int i = 0; i < ARRAY; ++i) { 427 for (int i = 0; i < ARRAY; ++i) {
428 accum += SkCLZ_portable(fData[i]); 428 accum += SkCLZ_portable(fData[i]);
429 } 429 }
430 this->process(accum); 430 this->process(accum);
431 } 431 }
432 } else { 432 } else {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } 468 }
469 469
470 bool isSuitableFor(Backend backend) override { 470 bool isSuitableFor(Backend backend) override {
471 return backend == kNonRendering_Backend; 471 return backend == kNonRendering_Backend;
472 } 472 }
473 473
474 // just so the compiler doesn't remove our loops 474 // just so the compiler doesn't remove our loops
475 virtual void process(int) {} 475 virtual void process(int) {}
476 476
477 protected: 477 protected:
478 void onDraw(const int loops, SkCanvas*) override { 478 void onDraw(int loops, SkCanvas*) override {
479 int accum = 0; 479 int accum = 0;
480 480
481 for (int j = 0; j < loops; ++j) { 481 for (int j = 0; j < loops; ++j) {
482 for (int i = 0; i < ARRAY; ++i) { 482 for (int i = 0; i < ARRAY; ++i) {
483 accum += fVec[i].normalize(); 483 accum += fVec[i].normalize();
484 } 484 }
485 this->process(accum); 485 this->process(accum);
486 } 486 }
487 } 487 }
488 488
(...skipping 23 matching lines...) Expand all
512 fData[i] = rand.nextSScalar1(); 512 fData[i] = rand.nextSScalar1();
513 } 513 }
514 514
515 } 515 }
516 516
517 bool isSuitableFor(Backend backend) override { 517 bool isSuitableFor(Backend backend) override {
518 return backend == kNonRendering_Backend; 518 return backend == kNonRendering_Backend;
519 } 519 }
520 520
521 protected: 521 protected:
522 void onDraw(const int loops, SkCanvas*) override { 522 void onDraw(int loops, SkCanvas*) override {
523 for (int j = 0; j < loops; ++j) { 523 for (int j = 0; j < loops; ++j) {
524 for (int i = 0; i < N - 4; ++i) { 524 for (int i = 0; i < N - 4; ++i) {
525 fResult[i] = SkFloatToFixed(fData[i]); 525 fResult[i] = SkFloatToFixed(fData[i]);
526 } 526 }
527 } 527 }
528 528
529 SkPaint paint; 529 SkPaint paint;
530 if (paint.getAlpha() == 0) { 530 if (paint.getAlpha() == 0) {
531 SkDebugf("%d\n", fResult[0]); 531 SkDebugf("%d\n", fResult[0]);
532 } 532 }
(...skipping 19 matching lines...) Expand all
552 552
553 bool isSuitableFor(Backend backend) override { 553 bool isSuitableFor(Backend backend) override {
554 return backend == kNonRendering_Backend; 554 return backend == kNonRendering_Backend;
555 } 555 }
556 556
557 protected: 557 protected:
558 const char* onGetName() override { 558 const char* onGetName() override {
559 return fName.c_str(); 559 return fName.c_str();
560 } 560 }
561 561
562 void onDraw(const int loops, SkCanvas*) override { 562 void onDraw(int loops, SkCanvas*) override {
563 volatile T a = 0, b = 0; 563 volatile T a = 0, b = 0;
564 T div = 0, mod = 0; 564 T div = 0, mod = 0;
565 for (int i = 0; i < loops; i++) { 565 for (int i = 0; i < loops; i++) {
566 if ((T)i == 0) continue; // Small T will wrap around. 566 if ((T)i == 0) continue; // Small T will wrap around.
567 SkTDivMod((T)(i+1), (T)i, &div, &mod); 567 SkTDivMod((T)(i+1), (T)i, &div, &mod);
568 a ^= div; 568 a ^= div;
569 b ^= mod; 569 b ^= mod;
570 } 570 }
571 } 571 }
572 }; 572 };
(...skipping 26 matching lines...) Expand all
599 599
600 DEF_BENCH( return new FloorBench(false); ) 600 DEF_BENCH( return new FloorBench(false); )
601 DEF_BENCH( return new FloorBench(true); ) 601 DEF_BENCH( return new FloorBench(true); )
602 602
603 DEF_BENCH( return new CLZBench(false); ) 603 DEF_BENCH( return new CLZBench(false); )
604 DEF_BENCH( return new CLZBench(true); ) 604 DEF_BENCH( return new CLZBench(true); )
605 605
606 DEF_BENCH( return new NormalizeBench(); ) 606 DEF_BENCH( return new NormalizeBench(); )
607 607
608 DEF_BENCH( return new FixedMathBench(); ) 608 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