OLD | NEW |
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 Loading... |
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 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { | 34 bool isSuitableFor(Backend backend) SK_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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { | 288 bool isSuitableFor(Backend backend) SK_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 Loading... |
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 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { | 356 bool isSuitableFor(Backend backend) SK_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 Loading... |
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 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { | 417 bool isSuitableFor(Backend backend) SK_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 Loading... |
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 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { | 473 bool isSuitableFor(Backend backend) SK_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 Loading... |
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 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { | 520 bool isSuitableFor(Backend backend) SK_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 Loading... |
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 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { | 556 bool isSuitableFor(Backend backend) SK_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 Loading... |
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(); ) |
OLD | NEW |