Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: bench/ChecksumBench.cpp

Issue 99893003: Simplify benchmark internal API. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « bench/ChartBench.cpp ('k') | bench/ChromeBench.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 switch (fType) { 44 switch (fType) {
45 case kChecksum_ChecksumType: return "compute_checksum"; 45 case kChecksum_ChecksumType: return "compute_checksum";
46 case kMD5_ChecksumType: return "compute_md5"; 46 case kMD5_ChecksumType: return "compute_md5";
47 case kSHA1_ChecksumType: return "compute_sha1"; 47 case kSHA1_ChecksumType: return "compute_sha1";
48 case kMurmur3_ChecksumType: return "compute_murmur3"; 48 case kMurmur3_ChecksumType: return "compute_murmur3";
49 49
50 default: SK_CRASH(); return ""; 50 default: SK_CRASH(); return "";
51 } 51 }
52 } 52 }
53 53
54 virtual void onDraw(SkCanvas*) { 54 virtual void onDraw(const int loops, SkCanvas*) {
55 switch (fType) { 55 switch (fType) {
56 case kChecksum_ChecksumType: { 56 case kChecksum_ChecksumType: {
57 for (int i = 0; i < this->getLoops(); i++) { 57 for (int i = 0; i < loops; i++) {
58 volatile uint32_t result = SkChecksum::Compute(fData, sizeof (fData)); 58 volatile uint32_t result = SkChecksum::Compute(fData, sizeof (fData));
59 sk_ignore_unused_variable(result); 59 sk_ignore_unused_variable(result);
60 } 60 }
61 } break; 61 } break;
62 case kMD5_ChecksumType: { 62 case kMD5_ChecksumType: {
63 for (int i = 0; i < this->getLoops(); i++) { 63 for (int i = 0; i < loops; i++) {
64 SkMD5 md5; 64 SkMD5 md5;
65 md5.update(reinterpret_cast<uint8_t*>(fData), sizeof(fData)) ; 65 md5.update(reinterpret_cast<uint8_t*>(fData), sizeof(fData)) ;
66 SkMD5::Digest digest; 66 SkMD5::Digest digest;
67 md5.finish(digest); 67 md5.finish(digest);
68 } 68 }
69 } break; 69 } break;
70 case kSHA1_ChecksumType: { 70 case kSHA1_ChecksumType: {
71 for (int i = 0; i < this->getLoops(); i++) { 71 for (int i = 0; i < loops; i++) {
72 SkSHA1 sha1; 72 SkSHA1 sha1;
73 sha1.update(reinterpret_cast<uint8_t*>(fData), sizeof(fData) ); 73 sha1.update(reinterpret_cast<uint8_t*>(fData), sizeof(fData) );
74 SkSHA1::Digest digest; 74 SkSHA1::Digest digest;
75 sha1.finish(digest); 75 sha1.finish(digest);
76 } 76 }
77 } break; 77 } break;
78 case kMurmur3_ChecksumType: { 78 case kMurmur3_ChecksumType: {
79 for (int i = 0; i < this->getLoops(); 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 SkBenchmark 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); )
OLDNEW
« no previous file with comments | « bench/ChartBench.cpp ('k') | bench/ChromeBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698