| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBenchmark.h" | 8 #include "SkBenchmark.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkUtils.h" | 10 #include "SkUtils.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 VALUE32 = 0x12345678, | 21 VALUE32 = 0x12345678, |
| 22 VALUE16 = 0x1234 | 22 VALUE16 = 0x1234 |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 enum MemsetType { | 25 enum MemsetType { |
| 26 MEMSET16 = 16, | 26 MEMSET16 = 16, |
| 27 MEMSET32 = 32 | 27 MEMSET32 = 32 |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 public: | 30 public: |
| 31 MemsetBench(void* param, MemsetType type, size_t minSize, size_t maxSize) :
INHERITED(param) { | 31 MemsetBench(MemsetType type, size_t minSize, size_t maxSize) { |
| 32 SkASSERT((minSize < maxSize) && (maxSize <= kBufferSize)); | 32 SkASSERT((minSize < maxSize) && (maxSize <= kBufferSize)); |
| 33 fMinSize = minSize; | 33 fMinSize = minSize; |
| 34 fMaxSize = maxSize; | 34 fMaxSize = maxSize; |
| 35 fName.printf("memset%d_" SK_SIZE_T_SPECIFIER "_" SK_SIZE_T_SPECIFIER, | 35 fName.printf("memset%d_" SK_SIZE_T_SPECIFIER "_" SK_SIZE_T_SPECIFIER, |
| 36 type, minSize, maxSize); | 36 type, minSize, maxSize); |
| 37 fIsRendering = false; | 37 fIsRendering = false; |
| 38 } | 38 } |
| 39 | 39 |
| 40 virtual void performTest() = 0; | 40 virtual void performTest() = 0; |
| 41 | 41 |
| 42 protected: | 42 protected: |
| 43 virtual const char* onGetName() SK_OVERRIDE { | 43 virtual const char* onGetName() SK_OVERRIDE { |
| 44 return fName.c_str(); | 44 return fName.c_str(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 47 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 48 for (int i = 0; i < this->getLoops(); ++i) { | 48 for (int i = 0; i < this->getLoops(); ++i) { |
| 49 this->performTest(); | 49 this->performTest(); |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 typedef SkBenchmark INHERITED; | 54 typedef SkBenchmark INHERITED; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 class Memset32Bench : public MemsetBench { | 57 class Memset32Bench : public MemsetBench { |
| 58 uint32_t kBuffer[kBufferSize + 3]; | 58 uint32_t kBuffer[kBufferSize + 3]; |
| 59 public: | 59 public: |
| 60 Memset32Bench(void* param, size_t minSize, size_t maxSize) | 60 Memset32Bench(size_t minSize, size_t maxSize) |
| 61 : INHERITED(param, MEMSET32, minSize, maxSize) {} | 61 : INHERITED(MEMSET32, minSize, maxSize) {} |
| 62 | 62 |
| 63 protected: | 63 protected: |
| 64 virtual void performTest() SK_OVERRIDE { | 64 virtual void performTest() SK_OVERRIDE { |
| 65 for(size_t j = fMinSize; j < fMaxSize; ++j){ | 65 for(size_t j = fMinSize; j < fMaxSize; ++j){ |
| 66 sk_memset32(kBuffer, VALUE32, j); | 66 sk_memset32(kBuffer, VALUE32, j); |
| 67 sk_memset32(kBuffer + 1, VALUE32, j); | 67 sk_memset32(kBuffer + 1, VALUE32, j); |
| 68 sk_memset32(kBuffer + 2, VALUE32, j); | 68 sk_memset32(kBuffer + 2, VALUE32, j); |
| 69 sk_memset32(kBuffer + 3, VALUE32, j); | 69 sk_memset32(kBuffer + 3, VALUE32, j); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 private: | 72 private: |
| 73 typedef MemsetBench INHERITED; | 73 typedef MemsetBench INHERITED; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 class Memset16Bench : public MemsetBench { | 76 class Memset16Bench : public MemsetBench { |
| 77 uint16_t kBuffer[kBufferSize + 7]; | 77 uint16_t kBuffer[kBufferSize + 7]; |
| 78 public: | 78 public: |
| 79 Memset16Bench(void* param, size_t minSize, size_t maxSize) | 79 Memset16Bench(size_t minSize, size_t maxSize) |
| 80 : INHERITED(param, MEMSET16, minSize, maxSize) {} | 80 : INHERITED(MEMSET16, minSize, maxSize) {} |
| 81 | 81 |
| 82 protected: | 82 protected: |
| 83 virtual void performTest() SK_OVERRIDE { | 83 virtual void performTest() SK_OVERRIDE { |
| 84 for(size_t j = fMinSize; j < fMaxSize; ++j){ | 84 for(size_t j = fMinSize; j < fMaxSize; ++j){ |
| 85 sk_memset16(kBuffer, VALUE16, j); | 85 sk_memset16(kBuffer, VALUE16, j); |
| 86 sk_memset16(kBuffer + 1, VALUE16, j); | 86 sk_memset16(kBuffer + 1, VALUE16, j); |
| 87 sk_memset16(kBuffer + 2, VALUE16, j); | 87 sk_memset16(kBuffer + 2, VALUE16, j); |
| 88 sk_memset16(kBuffer + 3, VALUE16, j); | 88 sk_memset16(kBuffer + 3, VALUE16, j); |
| 89 sk_memset16(kBuffer + 4, VALUE16, j); | 89 sk_memset16(kBuffer + 4, VALUE16, j); |
| 90 sk_memset16(kBuffer + 5, VALUE16, j); | 90 sk_memset16(kBuffer + 5, VALUE16, j); |
| 91 sk_memset16(kBuffer + 6, VALUE16, j); | 91 sk_memset16(kBuffer + 6, VALUE16, j); |
| 92 sk_memset16(kBuffer + 7, VALUE16, j); | 92 sk_memset16(kBuffer + 7, VALUE16, j); |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 private: | 95 private: |
| 96 typedef MemsetBench INHERITED; | 96 typedef MemsetBench INHERITED; |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 DEF_BENCH(return new Memset32Bench(p, 1, 600);) | 99 DEF_BENCH(return new Memset32Bench(1, 600);) |
| 100 DEF_BENCH(return new Memset32Bench(p, 600, 800);) | 100 DEF_BENCH(return new Memset32Bench(600, 800);) |
| 101 DEF_BENCH(return new Memset32Bench(p, 800, 1000);) | 101 DEF_BENCH(return new Memset32Bench(800, 1000);) |
| 102 DEF_BENCH(return new Memset32Bench(p, 1000, 2000);) | 102 DEF_BENCH(return new Memset32Bench(1000, 2000);) |
| 103 DEF_BENCH(return new Memset32Bench(p, 2000, 3000);) | 103 DEF_BENCH(return new Memset32Bench(2000, 3000);) |
| 104 DEF_BENCH(return new Memset32Bench(p, 3000, 4000);) | 104 DEF_BENCH(return new Memset32Bench(3000, 4000);) |
| 105 DEF_BENCH(return new Memset32Bench(p, 4000, 5000);) | 105 DEF_BENCH(return new Memset32Bench(4000, 5000);) |
| 106 | 106 |
| 107 DEF_BENCH(return new Memset16Bench(p, 1, 600);) | 107 DEF_BENCH(return new Memset16Bench(1, 600);) |
| 108 DEF_BENCH(return new Memset16Bench(p, 600, 800);) | 108 DEF_BENCH(return new Memset16Bench(600, 800);) |
| 109 DEF_BENCH(return new Memset16Bench(p, 800, 1000);) | 109 DEF_BENCH(return new Memset16Bench(800, 1000);) |
| 110 DEF_BENCH(return new Memset16Bench(p, 1000, 2000);) | 110 DEF_BENCH(return new Memset16Bench(1000, 2000);) |
| 111 DEF_BENCH(return new Memset16Bench(p, 2000, 3000);) | 111 DEF_BENCH(return new Memset16Bench(2000, 3000);) |
| 112 DEF_BENCH(return new Memset16Bench(p, 3000, 4000);) | 112 DEF_BENCH(return new Memset16Bench(3000, 4000);) |
| 113 DEF_BENCH(return new Memset16Bench(p, 4000, 5000);) | 113 DEF_BENCH(return new Memset16Bench(4000, 5000);) |
| OLD | NEW |