| OLD | NEW |
| 1 #include "SkBenchmark.h" | 1 #include "SkBenchmark.h" |
| 2 #include "SkColorPriv.h" | 2 #include "SkColorPriv.h" |
| 3 #include "SkMatrix.h" | 3 #include "SkMatrix.h" |
| 4 #include "SkRandom.h" | 4 #include "SkRandom.h" |
| 5 #include "SkString.h" | 5 #include "SkString.h" |
| 6 #include "SkPaint.h" | 6 #include "SkPaint.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 11 matching lines...) Expand all Loading... |
| 22 SkString fName; | 22 SkString fName; |
| 23 float fSrc[kBuffer], fDst[kBuffer]; | 23 float fSrc[kBuffer], fDst[kBuffer]; |
| 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 fIsRendering = false; | 34 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
| 35 return backend == kNonRendering_Backend; |
| 34 } | 36 } |
| 35 | 37 |
| 36 virtual void performTest(float* SK_RESTRICT dst, | 38 virtual void performTest(float* SK_RESTRICT dst, |
| 37 const float* SK_RESTRICT src, | 39 const float* SK_RESTRICT src, |
| 38 int count) = 0; | 40 int count) = 0; |
| 39 | 41 |
| 40 protected: | 42 protected: |
| 41 virtual int mulLoopCount() const { return 1; } | 43 virtual int mulLoopCount() const { return 1; } |
| 42 | 44 |
| 43 virtual const char* onGetName() { | 45 virtual const char* onGetName() { |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 fData[i] = rand.nextSScalar1(); | 276 fData[i] = rand.nextSScalar1(); |
| 275 } | 277 } |
| 276 | 278 |
| 277 if (index < 0) { | 279 if (index < 0) { |
| 278 fProc = NULL; | 280 fProc = NULL; |
| 279 fName = "isfinite_rect"; | 281 fName = "isfinite_rect"; |
| 280 } else { | 282 } else { |
| 281 fProc = gRec[index].fProc; | 283 fProc = gRec[index].fProc; |
| 282 fName = gRec[index].fName; | 284 fName = gRec[index].fName; |
| 283 } | 285 } |
| 284 fIsRendering = false; | 286 } |
| 287 |
| 288 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
| 289 return backend == kNonRendering_Backend; |
| 285 } | 290 } |
| 286 | 291 |
| 287 protected: | 292 protected: |
| 288 virtual void onDraw(SkCanvas*) { | 293 virtual void onDraw(SkCanvas*) { |
| 289 IsFiniteProc proc = fProc; | 294 IsFiniteProc proc = fProc; |
| 290 const float* data = fData; | 295 const float* data = fData; |
| 291 // 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 |
| 292 int counter = 0; | 297 int counter = 0; |
| 293 | 298 |
| 294 if (proc) { | 299 if (proc) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 344 |
| 340 for (int i = 0; i < ARRAY; ++i) { | 345 for (int i = 0; i < ARRAY; ++i) { |
| 341 fData[i] = rand.nextSScalar1(); | 346 fData[i] = rand.nextSScalar1(); |
| 342 } | 347 } |
| 343 | 348 |
| 344 if (fast) { | 349 if (fast) { |
| 345 fName = "floor_fast"; | 350 fName = "floor_fast"; |
| 346 } else { | 351 } else { |
| 347 fName = "floor_std"; | 352 fName = "floor_std"; |
| 348 } | 353 } |
| 349 fIsRendering = false; | 354 } |
| 355 |
| 356 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
| 357 return backend == kNonRendering_Backend; |
| 350 } | 358 } |
| 351 | 359 |
| 352 virtual void process(float) {} | 360 virtual void process(float) {} |
| 353 | 361 |
| 354 protected: | 362 protected: |
| 355 virtual void onDraw(SkCanvas*) { | 363 virtual void onDraw(SkCanvas*) { |
| 356 SkRandom rand; | 364 SkRandom rand; |
| 357 float accum = 0; | 365 float accum = 0; |
| 358 const float* data = fData; | 366 const float* data = fData; |
| 359 | 367 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 SkRandom rand; | 405 SkRandom rand; |
| 398 for (int i = 0; i < ARRAY; ++i) { | 406 for (int i = 0; i < ARRAY; ++i) { |
| 399 fData[i] = rand.nextU(); | 407 fData[i] = rand.nextU(); |
| 400 } | 408 } |
| 401 | 409 |
| 402 if (fUsePortable) { | 410 if (fUsePortable) { |
| 403 fName = "clz_portable"; | 411 fName = "clz_portable"; |
| 404 } else { | 412 } else { |
| 405 fName = "clz_intrinsic"; | 413 fName = "clz_intrinsic"; |
| 406 } | 414 } |
| 407 fIsRendering = false; | 415 } |
| 416 |
| 417 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
| 418 return backend == kNonRendering_Backend; |
| 408 } | 419 } |
| 409 | 420 |
| 410 // just so the compiler doesn't remove our loops | 421 // just so the compiler doesn't remove our loops |
| 411 virtual void process(int) {} | 422 virtual void process(int) {} |
| 412 | 423 |
| 413 protected: | 424 protected: |
| 414 virtual void onDraw(SkCanvas*) { | 425 virtual void onDraw(SkCanvas*) { |
| 415 int accum = 0; | 426 int accum = 0; |
| 416 | 427 |
| 417 if (fUsePortable) { | 428 if (fUsePortable) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 SkVector fVec[ARRAY]; | 461 SkVector fVec[ARRAY]; |
| 451 | 462 |
| 452 public: | 463 public: |
| 453 NormalizeBench() { | 464 NormalizeBench() { |
| 454 SkRandom rand; | 465 SkRandom rand; |
| 455 for (int i = 0; i < ARRAY; ++i) { | 466 for (int i = 0; i < ARRAY; ++i) { |
| 456 fVec[i].set(rand.nextSScalar1(), rand.nextSScalar1()); | 467 fVec[i].set(rand.nextSScalar1(), rand.nextSScalar1()); |
| 457 } | 468 } |
| 458 | 469 |
| 459 fName = "point_normalize"; | 470 fName = "point_normalize"; |
| 460 fIsRendering = false; | 471 } |
| 472 |
| 473 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
| 474 return backend == kNonRendering_Backend; |
| 461 } | 475 } |
| 462 | 476 |
| 463 // just so the compiler doesn't remove our loops | 477 // just so the compiler doesn't remove our loops |
| 464 virtual void process(int) {} | 478 virtual void process(int) {} |
| 465 | 479 |
| 466 protected: | 480 protected: |
| 467 virtual void onDraw(SkCanvas*) { | 481 virtual void onDraw(SkCanvas*) { |
| 468 int accum = 0; | 482 int accum = 0; |
| 469 | 483 |
| 470 for (int j = 0; j < this->getLoops(); ++j) { | 484 for (int j = 0; j < this->getLoops(); ++j) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 494 float fData[N]; | 508 float fData[N]; |
| 495 SkFixed fResult[N]; | 509 SkFixed fResult[N]; |
| 496 public: | 510 public: |
| 497 | 511 |
| 498 FixedMathBench() { | 512 FixedMathBench() { |
| 499 SkRandom rand; | 513 SkRandom rand; |
| 500 for (int i = 0; i < this->getLoops(); ++i) { | 514 for (int i = 0; i < this->getLoops(); ++i) { |
| 501 fData[i%N] = rand.nextSScalar1(); | 515 fData[i%N] = rand.nextSScalar1(); |
| 502 } | 516 } |
| 503 | 517 |
| 504 fIsRendering = false; | 518 } |
| 519 |
| 520 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
| 521 return backend == kNonRendering_Backend; |
| 505 } | 522 } |
| 506 | 523 |
| 507 protected: | 524 protected: |
| 508 virtual void onDraw(SkCanvas*) { | 525 virtual void onDraw(SkCanvas*) { |
| 509 for (int j = 0; j < this->getLoops(); ++j) { | 526 for (int j = 0; j < this->getLoops(); ++j) { |
| 510 for (int i = 0; i < N - 4; ++i) { | 527 for (int i = 0; i < N - 4; ++i) { |
| 511 fResult[i] = SkFloatToFixed(fData[i]); | 528 fResult[i] = SkFloatToFixed(fData[i]); |
| 512 } | 529 } |
| 513 } | 530 } |
| 514 | 531 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 527 }; | 544 }; |
| 528 | 545 |
| 529 /////////////////////////////////////////////////////////////////////////////// | 546 /////////////////////////////////////////////////////////////////////////////// |
| 530 | 547 |
| 531 template <typename T> | 548 template <typename T> |
| 532 class DivModBench : public SkBenchmark { | 549 class DivModBench : public SkBenchmark { |
| 533 SkString fName; | 550 SkString fName; |
| 534 public: | 551 public: |
| 535 explicit DivModBench(const char* name) { | 552 explicit DivModBench(const char* name) { |
| 536 fName.printf("divmod_%s", name); | 553 fName.printf("divmod_%s", name); |
| 537 fIsRendering = false; | 554 } |
| 555 |
| 556 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
| 557 return backend == kNonRendering_Backend; |
| 538 } | 558 } |
| 539 | 559 |
| 540 protected: | 560 protected: |
| 541 virtual const char* onGetName() { | 561 virtual const char* onGetName() { |
| 542 return fName.c_str(); | 562 return fName.c_str(); |
| 543 } | 563 } |
| 544 | 564 |
| 545 virtual void onDraw(SkCanvas*) { | 565 virtual void onDraw(SkCanvas*) { |
| 546 volatile T a = 0, b = 0; | 566 volatile T a = 0, b = 0; |
| 547 T div = 0, mod = 0; | 567 T div = 0, mod = 0; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 | 602 |
| 583 DEF_BENCH( return new FloorBench(false); ) | 603 DEF_BENCH( return new FloorBench(false); ) |
| 584 DEF_BENCH( return new FloorBench(true); ) | 604 DEF_BENCH( return new FloorBench(true); ) |
| 585 | 605 |
| 586 DEF_BENCH( return new CLZBench(false); ) | 606 DEF_BENCH( return new CLZBench(false); ) |
| 587 DEF_BENCH( return new CLZBench(true); ) | 607 DEF_BENCH( return new CLZBench(true); ) |
| 588 | 608 |
| 589 DEF_BENCH( return new NormalizeBench(); ) | 609 DEF_BENCH( return new NormalizeBench(); ) |
| 590 | 610 |
| 591 DEF_BENCH( return new FixedMathBench(); ) | 611 DEF_BENCH( return new FixedMathBench(); ) |
| OLD | NEW |