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

Side by Side Diff: bench/MemoryBench.cpp

Issue 73643005: Implement a benchmark for GrResourceCache (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address comments Created 7 years, 1 month 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/MatrixBench.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"
11 #include "SkRandom.h" 11 #include "SkRandom.h"
12 #include "SkChunkAlloc.h" 12 #include "SkChunkAlloc.h"
13 #include "SkString.h" 13 #include "SkString.h"
14 14
15 class ChunkAllocBench : public SkBenchmark { 15 class ChunkAllocBench : public SkBenchmark {
16 SkString fName; 16 SkString fName;
17 size_t fMinSize; 17 size_t fMinSize;
18 public: 18 public:
19 ChunkAllocBench(size_t minSize) { 19 ChunkAllocBench(size_t minSize) {
20 fMinSize = minSize; 20 fMinSize = minSize;
21 fName.printf("chunkalloc_" SK_SIZE_T_SPECIFIER, minSize); 21 fName.printf("chunkalloc_" SK_SIZE_T_SPECIFIER, minSize);
22 fIsRendering = false; 22 }
23
24 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
25 return backend == kNonRendering_Backend;
23 } 26 }
24 27
25 protected: 28 protected:
26 virtual const char* onGetName() SK_OVERRIDE { 29 virtual const char* onGetName() SK_OVERRIDE {
27 return fName.c_str(); 30 return fName.c_str();
28 } 31 }
29 32
30 virtual void onDraw(SkCanvas*) SK_OVERRIDE { 33 virtual void onDraw(SkCanvas*) SK_OVERRIDE {
31 size_t inc = fMinSize >> 4; 34 size_t inc = fMinSize >> 4;
32 SkASSERT(inc > 0); 35 SkASSERT(inc > 0);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 , fUseCalloc(useCalloc) { 81 , fUseCalloc(useCalloc) {
79 fName.printf("memory_%s", useCalloc ? "calloc" : "malloc_bzero"); 82 fName.printf("memory_%s", useCalloc ? "calloc" : "malloc_bzero");
80 if (read && write) { 83 if (read && write) {
81 fName.appendf("_rw"); 84 fName.appendf("_rw");
82 } else if (read) { 85 } else if (read) {
83 fName.appendf("_r"); 86 fName.appendf("_r");
84 } else if (write) { 87 } else if (write) {
85 fName.appendf("_w"); 88 fName.appendf("_w");
86 } 89 }
87 fName.appendf("_"SK_SIZE_T_SPECIFIER, num); 90 fName.appendf("_"SK_SIZE_T_SPECIFIER, num);
88 fIsRendering = false; 91 }
92
93 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
94 return backend == kNonRendering_Backend;
89 } 95 }
90 96
91 protected: 97 protected:
92 virtual const char* onGetName() SK_OVERRIDE { 98 virtual const char* onGetName() SK_OVERRIDE {
93 return fName.c_str(); 99 return fName.c_str();
94 } 100 }
95 101
96 virtual void onDraw(SkCanvas*) SK_OVERRIDE { 102 virtual void onDraw(SkCanvas*) SK_OVERRIDE {
97 for (int i = 0; i < this->getLoops(); i++) { 103 for (int i = 0; i < this->getLoops(); i++) {
98 int* zeros = fUseCalloc ? calloc(fNum) : malloc_bzero(fNum); 104 int* zeros = fUseCalloc ? calloc(fNum) : malloc_bzero(fNum);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 DEF_BENCH(return new ZerosBench(300, 1, 1, 1)) 156 DEF_BENCH(return new ZerosBench(300, 1, 1, 1))
151 157
152 DEF_BENCH(return new ZerosBench(4, 0, 0, 0)) 158 DEF_BENCH(return new ZerosBench(4, 0, 0, 0))
153 DEF_BENCH(return new ZerosBench(4, 0, 0, 1)) 159 DEF_BENCH(return new ZerosBench(4, 0, 0, 1))
154 DEF_BENCH(return new ZerosBench(4, 0, 1, 0)) 160 DEF_BENCH(return new ZerosBench(4, 0, 1, 0))
155 DEF_BENCH(return new ZerosBench(4, 0, 1, 1)) 161 DEF_BENCH(return new ZerosBench(4, 0, 1, 1))
156 DEF_BENCH(return new ZerosBench(4, 1, 0, 0)) 162 DEF_BENCH(return new ZerosBench(4, 1, 0, 0))
157 DEF_BENCH(return new ZerosBench(4, 1, 0, 1)) 163 DEF_BENCH(return new ZerosBench(4, 1, 0, 1))
158 DEF_BENCH(return new ZerosBench(4, 1, 1, 0)) 164 DEF_BENCH(return new ZerosBench(4, 1, 1, 0))
159 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/MatrixBench.cpp ('k') | bench/MemsetBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698