OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "SkBenchmark.h" | 7 #include "SkBenchmark.h" |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkChecksum.h" | 9 #include "SkChecksum.h" |
10 #include "SkMD5.h" | 10 #include "SkMD5.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 class ComputeChecksumBench : public SkBenchmark { | 22 class ComputeChecksumBench : public SkBenchmark { |
23 enum { | 23 enum { |
24 U32COUNT = 256, | 24 U32COUNT = 256, |
25 SIZE = U32COUNT * 4, | 25 SIZE = U32COUNT * 4, |
26 }; | 26 }; |
27 uint32_t fData[U32COUNT]; | 27 uint32_t fData[U32COUNT]; |
28 ChecksumType fType; | 28 ChecksumType fType; |
29 | 29 |
30 public: | 30 public: |
31 ComputeChecksumBench(void* param, ChecksumType type) : INHERITED(param), fTy
pe(type) { | 31 ComputeChecksumBench(ChecksumType type) : fType(type) { |
32 SkRandom rand; | 32 SkRandom rand; |
33 for (int i = 0; i < U32COUNT; ++i) { | 33 for (int i = 0; i < U32COUNT; ++i) { |
34 fData[i] = rand.nextU(); | 34 fData[i] = rand.nextU(); |
35 } | 35 } |
36 fIsRendering = false; | 36 fIsRendering = false; |
37 } | 37 } |
38 | 38 |
39 protected: | 39 protected: |
40 virtual const char* onGetName() { | 40 virtual const char* onGetName() { |
41 switch (fType) { | 41 switch (fType) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 81 } |
82 | 82 |
83 } | 83 } |
84 | 84 |
85 private: | 85 private: |
86 typedef SkBenchmark INHERITED; | 86 typedef SkBenchmark INHERITED; |
87 }; | 87 }; |
88 | 88 |
89 /////////////////////////////////////////////////////////////////////////////// | 89 /////////////////////////////////////////////////////////////////////////////// |
90 | 90 |
91 static SkBenchmark* Fact0(void* p) { return new ComputeChecksumBench(p, kChecksu
m_ChecksumType); } | 91 DEF_BENCH( return new ComputeChecksumBench(kChecksum_ChecksumType); ) |
92 static SkBenchmark* Fact1(void* p) { return new ComputeChecksumBench(p, kMD5_Che
cksumType); } | 92 DEF_BENCH( return new ComputeChecksumBench(kMD5_ChecksumType); ) |
93 static SkBenchmark* Fact2(void* p) { return new ComputeChecksumBench(p, kSHA1_Ch
ecksumType); } | 93 DEF_BENCH( return new ComputeChecksumBench(kSHA1_ChecksumType); ) |
94 static SkBenchmark* Fact3(void* p) { return new ComputeChecksumBench(p, kMurmur3
_ChecksumType); } | 94 DEF_BENCH( return new ComputeChecksumBench(kMurmur3_ChecksumType); ) |
95 | |
96 | |
97 static BenchRegistry gReg0(Fact0); | |
98 static BenchRegistry gReg1(Fact1); | |
99 static BenchRegistry gReg2(Fact2); | |
100 static BenchRegistry gReg3(Fact3); | |
OLD | NEW |