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

Side by Side Diff: bench/GrMemoryPoolBench.cpp

Issue 23576015: Change old PRG to be SkLCGRandom; change new one to SkRandom (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix some spurious SkMWCRandoms 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/GameBench.cpp ('k') | bench/HairlinePathBench.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 // This tests a Gr class 8 // This tests a Gr class
9 #if SK_SUPPORT_GPU 9 #if SK_SUPPORT_GPU
10 10
(...skipping 29 matching lines...) Expand all
40 public: 40 public:
41 GrMemoryPoolBenchStack(void* param) : INHERITED(param) { 41 GrMemoryPoolBenchStack(void* param) : INHERITED(param) {
42 fIsRendering = false; 42 fIsRendering = false;
43 } 43 }
44 protected: 44 protected:
45 virtual const char* onGetName() { 45 virtual const char* onGetName() {
46 return "grmemorypool_stack"; 46 return "grmemorypool_stack";
47 } 47 }
48 48
49 virtual void onDraw(SkCanvas*) { 49 virtual void onDraw(SkCanvas*) {
50 SkMWCRandom r; 50 SkRandom r;
51 enum { 51 enum {
52 kMaxObjects = 4 * (1 << 10), 52 kMaxObjects = 4 * (1 << 10),
53 }; 53 };
54 A* objects[kMaxObjects]; 54 A* objects[kMaxObjects];
55 55
56 // We delete if a random [-1, 1] fixed pt is < the thresh. Otherwise, 56 // We delete if a random [-1, 1] fixed pt is < the thresh. Otherwise,
57 // we allocate. We start allocate-biased and ping-pong to delete-biased 57 // we allocate. We start allocate-biased and ping-pong to delete-biased
58 SkFixed delThresh = -SK_FixedHalf; 58 SkFixed delThresh = -SK_FixedHalf;
59 enum { 59 enum {
60 kSwitchThreshPeriod = N / (2 * kMaxObjects), 60 kSwitchThreshPeriod = N / (2 * kMaxObjects),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 public: 96 public:
97 GrMemoryPoolBenchRandom(void* param) : INHERITED(param) { 97 GrMemoryPoolBenchRandom(void* param) : INHERITED(param) {
98 fIsRendering = false; 98 fIsRendering = false;
99 } 99 }
100 protected: 100 protected:
101 virtual const char* onGetName() { 101 virtual const char* onGetName() {
102 return "grmemorypool_random"; 102 return "grmemorypool_random";
103 } 103 }
104 104
105 virtual void onDraw(SkCanvas*) { 105 virtual void onDraw(SkCanvas*) {
106 SkMWCRandom r; 106 SkRandom r;
107 enum { 107 enum {
108 kMaxObjects = 4 * (1 << 10), 108 kMaxObjects = 4 * (1 << 10),
109 }; 109 };
110 SkAutoTDelete<A> objects[kMaxObjects]; 110 SkAutoTDelete<A> objects[kMaxObjects];
111 111
112 for (int i = 0; i < N; i++) { 112 for (int i = 0; i < N; i++) {
113 uint32_t idx = r.nextRangeU(0, kMaxObjects-1); 113 uint32_t idx = r.nextRangeU(0, kMaxObjects-1);
114 if (NULL == objects[idx].get()) { 114 if (NULL == objects[idx].get()) {
115 objects[idx].reset(new A); 115 objects[idx].reset(new A);
116 } else { 116 } else {
(...skipping 17 matching lines...) Expand all
134 public: 134 public:
135 GrMemoryPoolBenchQueue(void* param) : INHERITED(param) { 135 GrMemoryPoolBenchQueue(void* param) : INHERITED(param) {
136 fIsRendering = false; 136 fIsRendering = false;
137 } 137 }
138 protected: 138 protected:
139 virtual const char* onGetName() { 139 virtual const char* onGetName() {
140 return "grmemorypool_queue"; 140 return "grmemorypool_queue";
141 } 141 }
142 142
143 virtual void onDraw(SkCanvas*) { 143 virtual void onDraw(SkCanvas*) {
144 SkMWCRandom r; 144 SkRandom r;
145 A* objects[M]; 145 A* objects[M];
146 for (int i = 0; i < N; i++) { 146 for (int i = 0; i < N; i++) {
147 uint32_t count = r.nextRangeU(0, M-1); 147 uint32_t count = r.nextRangeU(0, M-1);
148 for (uint32_t i = 0; i < count; i++) { 148 for (uint32_t i = 0; i < count; i++) {
149 objects[i] = new A; 149 objects[i] = new A;
150 } 150 }
151 for (uint32_t i = 0; i < count; i++) { 151 for (uint32_t i = 0; i < count; i++) {
152 delete objects[i]; 152 delete objects[i];
153 } 153 }
154 } 154 }
155 } 155 }
156 156
157 private: 157 private:
158 typedef SkBenchmark INHERITED; 158 typedef SkBenchmark INHERITED;
159 }; 159 };
160 160
161 /////////////////////////////////////////////////////////////////////////////// 161 ///////////////////////////////////////////////////////////////////////////////
162 162
163 static SkBenchmark* Fact1(void* p) { return new GrMemoryPoolBenchStack(p); } 163 static SkBenchmark* Fact1(void* p) { return new GrMemoryPoolBenchStack(p); }
164 static SkBenchmark* Fact2(void* p) { return new GrMemoryPoolBenchRandom(p); } 164 static SkBenchmark* Fact2(void* p) { return new GrMemoryPoolBenchRandom(p); }
165 static SkBenchmark* Fact3(void* p) { return new GrMemoryPoolBenchQueue(p); } 165 static SkBenchmark* Fact3(void* p) { return new GrMemoryPoolBenchQueue(p); }
166 166
167 static BenchRegistry gReg01(Fact1); 167 static BenchRegistry gReg01(Fact1);
168 static BenchRegistry gReg02(Fact2); 168 static BenchRegistry gReg02(Fact2);
169 static BenchRegistry gReg03(Fact3); 169 static BenchRegistry gReg03(Fact3);
170 170
171 #endif 171 #endif
OLDNEW
« no previous file with comments | « bench/GameBench.cpp ('k') | bench/HairlinePathBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698