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

Side by Side Diff: tools/PictureBenchmark.cpp

Issue 227603006: hack Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: yet more hackage Created 6 years, 8 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 | « tools/PictureBenchmark.h ('k') | tools/PictureRenderer.h » ('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 "SkBenchLogger.h" 8 #include "SkBenchLogger.h"
9 #include "BenchTimer.h" 9 #include "BenchTimer.h"
10 #include "PictureBenchmark.h" 10 #include "PictureBenchmark.h"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkPicture.h" 12 #include "SkPicture.h"
13 #include "SkString.h" 13 #include "SkString.h"
14 #include "picture_utils.h" 14 #include "picture_utils.h"
15 15
16 namespace sk_tools { 16 namespace sk_tools {
17 17
18 PictureBenchmark::PictureBenchmark() 18 PictureBenchmark::PictureBenchmark()
19 : fRepeats(1) 19 : fRepeats(1)
20 , fLogger(NULL) 20 , fLogger(NULL)
21 , fRenderer(NULL) 21 , fRenderer(NULL)
22 , fTimerResult(TimerData::kAvg_Result) 22 , fTimerResult(TimerData::kAvg_Result)
23 , fTimerTypes(0) 23 , fTimerTypes(0)
24 , fTimeIndividualTiles(false) 24 , fTimeIndividualTiles(false)
25 , fPurgeDecodedTex(false) 25 , fPurgeDecodedTex1(false)
26 , fPreprocess(false)
26 {} 27 {}
27 28
28 PictureBenchmark::~PictureBenchmark() { 29 PictureBenchmark::~PictureBenchmark() {
29 SkSafeUnref(fRenderer); 30 SkSafeUnref(fRenderer);
30 } 31 }
31 32
32 void PictureBenchmark::setTimersToShow(bool wall, 33 void PictureBenchmark::setTimersToShow(bool wall,
33 bool truncatedWall, 34 bool truncatedWall,
34 bool cpu, 35 bool cpu,
35 bool truncatedCpu, 36 bool truncatedCpu,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 70 }
70 71
71 SkASSERT(fRenderer != NULL); 72 SkASSERT(fRenderer != NULL);
72 if (NULL == fRenderer) { 73 if (NULL == fRenderer) {
73 return; 74 return;
74 } 75 }
75 76
76 fRenderer->init(pict, NULL, NULL, false); 77 fRenderer->init(pict, NULL, NULL, false);
77 78
78 // We throw this away to remove first time effects (such as paging in this p rogram) 79 // We throw this away to remove first time effects (such as paging in this p rogram)
79 fRenderer->setup(); 80 fRenderer->setup1();
81
82 if (fPreprocess) {
83 if (NULL != fRenderer->getCanvas()) {
84 fRenderer->getCanvas()->EXPERIMENTAL_optimize(pict);
85 }
86 }
87
80 fRenderer->render(NULL); 88 fRenderer->render(NULL);
81 fRenderer->resetState(true); // flush, swapBuffers and Finish 89 fRenderer->resetState(true); // flush, swapBuffers and Finish
82 90
83 if (fPurgeDecodedTex) { 91 if (fPreprocess) {
92 // pict->needsNewGenID();
93 if (NULL != fRenderer->getCanvas()) {
94 fRenderer->getCanvas()->EXPERIMENTAL_purge();
95 }
96 }
97
98 if (fPurgeDecodedTex1) {
84 fRenderer->purgeTextures(); 99 fRenderer->purgeTextures();
85 } 100 }
86 101
87 bool usingGpu = false; 102 bool usingGpu = false;
88 #if SK_SUPPORT_GPU 103 #if SK_SUPPORT_GPU
89 usingGpu = fRenderer->isUsingGpuDevice(); 104 usingGpu = fRenderer->isUsingGpuDevice();
90 #endif 105 #endif
91 106
92 uint32_t timerTypes = fTimerTypes; 107 uint32_t timerTypes = fTimerTypes;
93 if (!usingGpu) { 108 if (!usingGpu) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 168
154 longRunningTimer->start(); 169 longRunningTimer->start();
155 for (int inner = 0; inner < numInnerLoops; ++inner) { 170 for (int inner = 0; inner < numInnerLoops; ++inner) {
156 perTileTimer->start(); 171 perTileTimer->start();
157 tiledRenderer->drawCurrentTile(); 172 tiledRenderer->drawCurrentTile();
158 perTileTimer->truncatedEnd(); 173 perTileTimer->truncatedEnd();
159 tiledRenderer->resetState(false); // flush & swapBuffers, b ut don't Finish 174 tiledRenderer->resetState(false); // flush & swapBuffers, b ut don't Finish
160 perTileTimer->end(); 175 perTileTimer->end();
161 SkAssertResult(perTileTimerData.appendTimes(perTileTimer.get ())); 176 SkAssertResult(perTileTimerData.appendTimes(perTileTimer.get ()));
162 177
163 if (fPurgeDecodedTex) { 178 if (fPurgeDecodedTex1) {
164 fRenderer->purgeTextures(); 179 fRenderer->purgeTextures();
165 } 180 }
166 } 181 }
167 longRunningTimer->truncatedEnd(); 182 longRunningTimer->truncatedEnd();
168 tiledRenderer->resetState(true); // flush, swapBuffers and Finish 183 tiledRenderer->resetState(true); // flush, swapBuffers and Finish
169 longRunningTimer->end(); 184 longRunningTimer->end();
170 SkAssertResult(longRunningTimerData.appendTimes(longRunningTimer .get())); 185 SkAssertResult(longRunningTimerData.appendTimes(longRunningTimer .get()));
171 } 186 }
172 187
173 SkString configName = tiledRenderer->getConfigName(); 188 SkString configName = tiledRenderer->getConfigName();
174 configName.appendf(": tile [%i,%i] out of [%i,%i]", x, y, xTiles, yT iles); 189 configName.appendf(": tile [%i,%i] out of [%i,%i]", x, y, xTiles, yT iles);
175 190
176 // TODO(borenet): Turn off per-iteration tile time reporting for now . 191 // TODO(borenet): Turn off per-iteration tile time reporting for now .
177 // Avoiding logging the time for every iteration for each tile cuts 192 // Avoiding logging the time for every iteration for each tile cuts
178 // down on data file size by a significant amount. Re-enable this on ce 193 // down on data file size by a significant amount. Re-enable this on ce
179 // we're loading the bench data directly into a data store and are n o 194 // we're loading the bench data directly into a data store and are n o
180 // longer generating SVG graphs. 195 // longer generating SVG graphs.
181 #if 0 196 #if 0
182 SkString result = perTileTimerData.getResult(timeFormat.c_str(), fTi merResult, 197 SkString result = perTileTimerData.getResult(timeFormat.c_str(), fTi merResult,
183 configName.c_str(), tim erTypes); 198 configName.c_str(), tim erTypes);
184 result.append("\n"); 199 result.append("\n");
185 this->logProgress(result.c_str()); 200 this->logProgress(result.c_str());
186 #endif 201 #endif
187 202
188 if (fPurgeDecodedTex) { 203 if (fPurgeDecodedTex1) {
189 configName.append(" <withPurging>"); 204 configName.append(" <withPurging>");
190 } 205 }
191 configName.append(" <averaged>"); 206 configName.append(" <averaged>");
192 SkString longRunningResult = longRunningTimerData.getResult( 207 SkString longRunningResult = longRunningTimerData.getResult(
193 tiledRenderer->getNormalTimeFormat().c_str(), 208 tiledRenderer->getNormalTimeFormat().c_str(),
194 TimerData::kAvg_Result, 209 TimerData::kAvg_Result,
195 configName.c_str(), timerTypes, numInnerLoops); 210 configName.c_str(), timerTypes, numInnerLoops);
196 longRunningResult.append("\n"); 211 longRunningResult.append("\n");
197 this->logProgress(longRunningResult.c_str()); 212 this->logProgress(longRunningResult.c_str());
198 } 213 }
199 } else { 214 } else {
200 SkAutoTDelete<BenchTimer> longRunningTimer(this->setupTimer()); 215 SkAutoTDelete<BenchTimer> longRunningTimer(this->setupTimer());
201 TimerData longRunningTimerData(numOuterLoops); 216 TimerData longRunningTimerData(numOuterLoops);
202 217
203 for (int outer = 0; outer < numOuterLoops; ++outer) { 218 for (int outer = 0; outer < numOuterLoops; ++outer) {
204 SkAutoTDelete<BenchTimer> perRunTimer(this->setupTimer(false)); 219 SkAutoTDelete<BenchTimer> perRunTimer(this->setupTimer(false));
205 TimerData perRunTimerData(numInnerLoops); 220 TimerData perRunTimerData(numInnerLoops);
206 221
207 longRunningTimer->start(); 222 longRunningTimer->start();
208 for (int inner = 0; inner < numInnerLoops; ++inner) { 223 for (int inner = 0; inner < numInnerLoops; ++inner) {
209 fRenderer->setup(); 224 fRenderer->setup1();
210 225
211 perRunTimer->start(); 226 perRunTimer->start();
212 fRenderer->render(NULL); 227 fRenderer->render(NULL);
213 perRunTimer->truncatedEnd(); 228 perRunTimer->truncatedEnd();
214 fRenderer->resetState(false); // flush & swapBuffers, but don' t Finish 229 fRenderer->resetState(false); // flush & swapBuffers, but don' t Finish
215 perRunTimer->end(); 230 perRunTimer->end();
216 231
217 SkAssertResult(perRunTimerData.appendTimes(perRunTimer.get())); 232 SkAssertResult(perRunTimerData.appendTimes(perRunTimer.get()));
218 233
219 if (fPurgeDecodedTex) { 234 if (fPreprocess) {
235 // pict->needsNewGenID();
236 if (NULL != fRenderer->getCanvas()) {
237 fRenderer->getCanvas()->EXPERIMENTAL_purge();
238 }
239 }
240
241 if (fPurgeDecodedTex1) {
220 fRenderer->purgeTextures(); 242 fRenderer->purgeTextures();
221 } 243 }
244
222 } 245 }
223 longRunningTimer->truncatedEnd(); 246 longRunningTimer->truncatedEnd();
224 fRenderer->resetState(true); // flush, swapBuffers and Finish 247 fRenderer->resetState(true); // flush, swapBuffers and Finish
225 longRunningTimer->end(); 248 longRunningTimer->end();
226 SkAssertResult(longRunningTimerData.appendTimes(longRunningTimer.get ())); 249 SkAssertResult(longRunningTimerData.appendTimes(longRunningTimer.get ()));
227 } 250 }
228 251
229 SkString configName = fRenderer->getConfigName(); 252 SkString configName = fRenderer->getConfigName();
230 if (fPurgeDecodedTex) { 253 if (fPurgeDecodedTex1) {
231 configName.append(" <withPurging>"); 254 configName.append(" <withPurging>");
232 } 255 }
233 256
234 // Beware - since the per-run-timer doesn't ever include a glFinish it c an 257 // Beware - since the per-run-timer doesn't ever include a glFinish it c an
235 // report a lower time then the long-running-timer 258 // report a lower time then the long-running-timer
236 #if 0 259 #if 0
237 SkString result = perRunTimerData.getResult(timeFormat.c_str(), 260 SkString result = perRunTimerData.getResult(timeFormat.c_str(),
238 fTimerResult, 261 fTimerResult,
239 configName.c_str(), 262 configName.c_str(),
240 timerTypes); 263 timerTypes);
241 result.append("\n"); 264 result.append("\n");
242 265
243 this->logProgress(result.c_str()); 266 this->logProgress(result.c_str());
244 #else 267 #else
245 SkString result = longRunningTimerData.getResult(timeFormat.c_str(), 268 SkString result = longRunningTimerData.getResult(timeFormat.c_str(),
246 fTimerResult, 269 fTimerResult,
247 configName.c_str(), 270 configName.c_str(),
248 timerTypes, 271 timerTypes,
249 numInnerLoops); 272 numInnerLoops);
250 result.append("\n"); 273 result.append("\n");
251 this->logProgress(result.c_str()); 274 this->logProgress(result.c_str());
252 #endif 275 #endif
253 } 276 }
254 277
255 fRenderer->end(); 278 fRenderer->end();
256 } 279 }
257 280
258 } 281 }
OLDNEW
« no previous file with comments | « tools/PictureBenchmark.h ('k') | tools/PictureRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698