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

Side by Side Diff: bench/MemoryBench.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/MatrixConvolutionBench.cpp ('k') | bench/MemsetBench.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 7
8 #include "SkBenchmark.h" 8 #include "SkBenchmark.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 12 matching lines...) Expand all
23 23
24 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { 24 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
25 return backend == kNonRendering_Backend; 25 return backend == kNonRendering_Backend;
26 } 26 }
27 27
28 protected: 28 protected:
29 virtual const char* onGetName() SK_OVERRIDE { 29 virtual const char* onGetName() SK_OVERRIDE {
30 return fName.c_str(); 30 return fName.c_str();
31 } 31 }
32 32
33 virtual void onDraw(SkCanvas*) SK_OVERRIDE { 33 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
34 size_t inc = fMinSize >> 4; 34 size_t inc = fMinSize >> 4;
35 SkASSERT(inc > 0); 35 SkASSERT(inc > 0);
36 size_t total = fMinSize * 64; 36 size_t total = fMinSize * 64;
37 37
38 SkChunkAlloc alloc(fMinSize); 38 SkChunkAlloc alloc(fMinSize);
39 39
40 for (int i = 0; i < this->getLoops(); ++i) { 40 for (int i = 0; i < loops; ++i) {
41 size_t size = 0; 41 size_t size = 0;
42 int calls = 0; 42 int calls = 0;
43 while (size < total) { 43 while (size < total) {
44 alloc.allocThrow(inc); 44 alloc.allocThrow(inc);
45 size += inc; 45 size += inc;
46 calls += 1; 46 calls += 1;
47 } 47 }
48 alloc.reset(); 48 alloc.reset();
49 } 49 }
50 } 50 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { 93 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
94 return backend == kNonRendering_Backend; 94 return backend == kNonRendering_Backend;
95 } 95 }
96 96
97 protected: 97 protected:
98 virtual const char* onGetName() SK_OVERRIDE { 98 virtual const char* onGetName() SK_OVERRIDE {
99 return fName.c_str(); 99 return fName.c_str();
100 } 100 }
101 101
102 virtual void onDraw(SkCanvas*) SK_OVERRIDE { 102 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
103 for (int i = 0; i < this->getLoops(); i++) { 103 for (int i = 0; i < loops; i++) {
104 int* zeros = fUseCalloc ? calloc(fNum) : malloc_bzero(fNum); 104 int* zeros = fUseCalloc ? calloc(fNum) : malloc_bzero(fNum);
105 if (fRead) { 105 if (fRead) {
106 volatile int x = 15; 106 volatile int x = 15;
107 for (size_t j = 0; j < fNum; j++) { 107 for (size_t j = 0; j < fNum; j++) {
108 x ^= zeros[j]; 108 x ^= zeros[j];
109 } 109 }
110 } 110 }
111 if (fWrite) { 111 if (fWrite) {
112 for (size_t j = 0; j < fNum; j++) { 112 for (size_t j = 0; j < fNum; j++) {
113 zeros[j] = 15; 113 zeros[j] = 15;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 DEF_BENCH(return new ZerosBench(300, 1, 1, 1)) 156 DEF_BENCH(return new ZerosBench(300, 1, 1, 1))
157 157
158 DEF_BENCH(return new ZerosBench(4, 0, 0, 0)) 158 DEF_BENCH(return new ZerosBench(4, 0, 0, 0))
159 DEF_BENCH(return new ZerosBench(4, 0, 0, 1)) 159 DEF_BENCH(return new ZerosBench(4, 0, 0, 1))
160 DEF_BENCH(return new ZerosBench(4, 0, 1, 0)) 160 DEF_BENCH(return new ZerosBench(4, 0, 1, 0))
161 DEF_BENCH(return new ZerosBench(4, 0, 1, 1)) 161 DEF_BENCH(return new ZerosBench(4, 0, 1, 1))
162 DEF_BENCH(return new ZerosBench(4, 1, 0, 0)) 162 DEF_BENCH(return new ZerosBench(4, 1, 0, 0))
163 DEF_BENCH(return new ZerosBench(4, 1, 0, 1)) 163 DEF_BENCH(return new ZerosBench(4, 1, 0, 1))
164 DEF_BENCH(return new ZerosBench(4, 1, 1, 0)) 164 DEF_BENCH(return new ZerosBench(4, 1, 1, 0))
165 DEF_BENCH(return new ZerosBench(4, 1, 1, 1)) 165 DEF_BENCH(return new ZerosBench(4, 1, 1, 1))
OLDNEW
« no previous file with comments | « bench/MatrixConvolutionBench.cpp ('k') | bench/MemsetBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698