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 "Benchmark.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" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 default: SK_ABORT("Invalid Type"); return ""; | 45 default: SK_ABORT("Invalid Type"); return ""; |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 void onDraw(int loops, SkCanvas*) override { | 49 void onDraw(int loops, SkCanvas*) override { |
50 switch (fType) { | 50 switch (fType) { |
51 case kMD5_ChecksumType: { | 51 case kMD5_ChecksumType: { |
52 for (int i = 0; i < loops; i++) { | 52 for (int i = 0; i < loops; i++) { |
53 SkMD5 md5; | 53 SkMD5 md5; |
54 md5.update(reinterpret_cast<uint8_t*>(fData), sizeof(fData))
; | 54 md5.write(fData, sizeof(fData)); |
55 SkMD5::Digest digest; | 55 SkMD5::Digest digest; |
56 md5.finish(digest); | 56 md5.finish(digest); |
57 } | 57 } |
58 } break; | 58 } break; |
59 case kMurmur3_ChecksumType: { | 59 case kMurmur3_ChecksumType: { |
60 for (int i = 0; i < loops; i++) { | 60 for (int i = 0; i < loops; i++) { |
61 volatile uint32_t result = SkChecksum::Murmur3(fData, sizeof
(fData)); | 61 volatile uint32_t result = SkChecksum::Murmur3(fData, sizeof
(fData)); |
62 sk_ignore_unused_variable(result); | 62 sk_ignore_unused_variable(result); |
63 } | 63 } |
64 }break; | 64 }break; |
65 } | 65 } |
66 | 66 |
67 } | 67 } |
68 | 68 |
69 private: | 69 private: |
70 typedef Benchmark INHERITED; | 70 typedef Benchmark INHERITED; |
71 }; | 71 }; |
72 | 72 |
73 /////////////////////////////////////////////////////////////////////////////// | 73 /////////////////////////////////////////////////////////////////////////////// |
74 | 74 |
75 DEF_BENCH( return new ComputeChecksumBench(kMD5_ChecksumType); ) | 75 DEF_BENCH( return new ComputeChecksumBench(kMD5_ChecksumType); ) |
76 DEF_BENCH( return new ComputeChecksumBench(kMurmur3_ChecksumType); ) | 76 DEF_BENCH( return new ComputeChecksumBench(kMurmur3_ChecksumType); ) |
OLD | NEW |