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

Side by Side Diff: bench/MemoryBench.cpp

Issue 23478013: Major bench refactoring. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: merge with head agani Created 7 years, 3 months 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"
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
19 enum {
20 N = SkBENCHLOOP(1000)
21 };
22 public: 18 public:
23 ChunkAllocBench(void* param, size_t minSize) : INHERITED(param) { 19 ChunkAllocBench(void* param, size_t minSize) : INHERITED(param) {
24 fMinSize = minSize; 20 fMinSize = minSize;
25 fName.printf("chunkalloc_" SK_SIZE_T_SPECIFIER, minSize); 21 fName.printf("chunkalloc_" SK_SIZE_T_SPECIFIER, minSize);
26 fIsRendering = false; 22 fIsRendering = false;
27 } 23 }
28 24
29 protected: 25 protected:
30 virtual const char* onGetName() SK_OVERRIDE { 26 virtual const char* onGetName() SK_OVERRIDE {
31 return fName.c_str(); 27 return fName.c_str();
32 } 28 }
33 29
34 virtual void onDraw(SkCanvas*) SK_OVERRIDE { 30 virtual void onDraw(SkCanvas*) SK_OVERRIDE {
35 size_t inc = fMinSize >> 4; 31 size_t inc = fMinSize >> 4;
36 SkASSERT(inc > 0); 32 SkASSERT(inc > 0);
37 size_t total = fMinSize * 64; 33 size_t total = fMinSize * 64;
38 34
39 SkChunkAlloc alloc(fMinSize); 35 SkChunkAlloc alloc(fMinSize);
40 36
41 for (int i = 0; i < N; ++i) { 37 for (int i = 0; i < this->getLoops(); ++i) {
42 size_t size = 0; 38 size_t size = 0;
43 int calls = 0; 39 int calls = 0;
44 while (size < total) { 40 while (size < total) {
45 alloc.allocThrow(inc); 41 alloc.allocThrow(inc);
46 size += inc; 42 size += inc;
47 calls += 1; 43 calls += 1;
48 } 44 }
49 alloc.reset(); 45 alloc.reset();
50 } 46 }
51 } 47 }
52 48
53 private: 49 private:
54 typedef SkBenchmark INHERITED; 50 typedef SkBenchmark INHERITED;
55 }; 51 };
56 52
57 static SkBenchmark* F0(void* p) { return new ChunkAllocBench(p, 64); } 53 static SkBenchmark* F0(void* p) { return new ChunkAllocBench(p, 64); }
58 static SkBenchmark* F1(void* p) { return new ChunkAllocBench(p, 8*1024); } 54 static SkBenchmark* F1(void* p) { return new ChunkAllocBench(p, 8*1024); }
59 55
60 static BenchRegistry gR0(F0); 56 static BenchRegistry gR0(F0);
61 static BenchRegistry gR1(F1); 57 static BenchRegistry gR1(F1);
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