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 "Benchmark.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" |
11 #include "SkRandom.h" | 11 #include "SkRandom.h" |
12 #include "SkSHA1.h" | 12 #include "SkSHA1.h" |
13 #include "SkTemplates.h" | 13 #include "SkTemplates.h" |
14 | 14 |
15 enum ChecksumType { | 15 enum ChecksumType { |
16 kChecksum_ChecksumType, | 16 kChecksum_ChecksumType, |
17 kMD5_ChecksumType, | 17 kMD5_ChecksumType, |
18 kSHA1_ChecksumType, | 18 kSHA1_ChecksumType, |
19 kMurmur3_ChecksumType, | 19 kMurmur3_ChecksumType, |
20 }; | 20 }; |
21 | 21 |
22 class ComputeChecksumBench : public SkBenchmark { | 22 class ComputeChecksumBench : public Benchmark { |
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(ChecksumType type) : fType(type) { | 31 ComputeChecksumBench(ChecksumType type) : fType(type) { |
32 SkRandom rand; | 32 SkRandom rand; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 for (int i = 0; i < loops; i++) { | 79 for (int i = 0; i < loops; i++) { |
80 volatile uint32_t result = SkChecksum::Murmur3(fData, sizeof
(fData)); | 80 volatile uint32_t result = SkChecksum::Murmur3(fData, sizeof
(fData)); |
81 sk_ignore_unused_variable(result); | 81 sk_ignore_unused_variable(result); |
82 } | 82 } |
83 }break; | 83 }break; |
84 } | 84 } |
85 | 85 |
86 } | 86 } |
87 | 87 |
88 private: | 88 private: |
89 typedef SkBenchmark INHERITED; | 89 typedef Benchmark INHERITED; |
90 }; | 90 }; |
91 | 91 |
92 /////////////////////////////////////////////////////////////////////////////// | 92 /////////////////////////////////////////////////////////////////////////////// |
93 | 93 |
94 DEF_BENCH( return new ComputeChecksumBench(kChecksum_ChecksumType); ) | 94 DEF_BENCH( return new ComputeChecksumBench(kChecksum_ChecksumType); ) |
95 DEF_BENCH( return new ComputeChecksumBench(kMD5_ChecksumType); ) | 95 DEF_BENCH( return new ComputeChecksumBench(kMD5_ChecksumType); ) |
96 DEF_BENCH( return new ComputeChecksumBench(kSHA1_ChecksumType); ) | 96 DEF_BENCH( return new ComputeChecksumBench(kSHA1_ChecksumType); ) |
97 DEF_BENCH( return new ComputeChecksumBench(kMurmur3_ChecksumType); ) | 97 DEF_BENCH( return new ComputeChecksumBench(kMurmur3_ChecksumType); ) |
OLD | NEW |