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

Side by Side Diff: tools/bbh_shootout.cpp

Issue 23639003: bbh_shootout: Move bitmap rendering out of the timing codepath. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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 | « no previous file | no next file » | 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 2013 Google Inc. 2 * Copyright 2013 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 "BenchTimer.h" 8 #include "BenchTimer.h"
9 #include "LazyDecodeBitmap.h" 9 #include "LazyDecodeBitmap.h"
10 #include "PictureBenchmark.h" 10 #include "PictureBenchmark.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 SkDebugf("%s %s %s %d times...\n", msgPrefix.c_str(), msg, path.c_str(), num Repeats); 232 SkDebugf("%s %s %s %d times...\n", msgPrefix.c_str(), msg, path.c_str(), num Repeats);
233 for (int i = 0; i < numRepeats; ++i) { 233 for (int i = 0; i < numRepeats; ++i) {
234 // Set up the bitmap. 234 // Set up the bitmap.
235 SkBitmap** out = NULL; 235 SkBitmap** out = NULL;
236 if (i == 0 && kRTree_BenchmarkType == benchmarkType && isPlayback) { 236 if (i == 0 && kRTree_BenchmarkType == benchmarkType && isPlayback) {
237 out = &bitmap; 237 out = &bitmap;
238 } 238 }
239 239
240 renderer->setup(); 240 renderer->setup();
241 // Render once to fill caches. 241 // Render once to fill caches. Fill bitmap during the first iteration.
242 renderer->render(NULL); 242 renderer->render(NULL, out);
243 // Render again to measure 243 // Render again to measure
244 timer->start(); 244 timer->start();
245 bool result = renderer->render(NULL, out); 245 bool result = renderer->render(NULL);
246 timer->end(); 246 timer->end();
247 247
248 // We only care about a false result on playback. RecordPictureRenderer: :render will always 248 // We only care about a false result on playback. RecordPictureRenderer: :render will always
249 // return false because we are passing a NULL file name on purpose; whic h is fine. 249 // return false because we are passing a NULL file name on purpose; whic h is fine.
250 if (isPlayback && !result) { 250 if (isPlayback && !result) {
251 SkDebugf("Error rendering during playback.\n"); 251 SkDebugf("Error rendering during playback.\n");
252 } 252 }
253 } 253 }
254 if (bitmap) { 254 if (bitmap) {
255 SkAutoTDelete<SkBitmap> bmDeleter(bitmap); 255 SkAutoTDelete<SkBitmap> bmDeleter(bitmap);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 recordOut.writeText(out.c_str()); 381 recordOut.writeText(out.c_str());
382 } 382 }
383 if (BenchmarkControl::GetBenchmarkFunc(i) == &benchmark_playback) { 383 if (BenchmarkControl::GetBenchmarkFunc(i) == &benchmark_playback) {
384 playbackOut.writeText(out.c_str()); 384 playbackOut.writeText(out.c_str());
385 } 385 }
386 } 386 }
387 recordOut.writeText("\n"); 387 recordOut.writeText("\n");
388 playbackOut.writeText("\n"); 388 playbackOut.writeText("\n");
389 // Write to file, and save recording averages. 389 // Write to file, and save recording averages.
390 SkScalar avgRecord = SkIntToScalar(0); 390 SkScalar avgRecord = SkIntToScalar(0);
391 SkScalar avgPlayback = SkIntToScalar(0);
391 SkScalar avgRecordRTree = SkIntToScalar(0); 392 SkScalar avgRecordRTree = SkIntToScalar(0);
393 SkScalar avgPlaybackRTree = SkIntToScalar(0);
392 for (int i = 0; i < argc - 1; ++i) { 394 for (int i = 0; i < argc - 1; ++i) {
393 SkString pbLine; 395 SkString pbLine;
394 SkString recLine; 396 SkString recLine;
395 // ==== Write record info 397 // ==== Write record info
396 recLine.printf("%d ", i); 398 recLine.printf("%d ", i);
397 SkScalar cpuTime = histograms[BenchmarkControl::kNormalRecord][i].fCpuTi me; 399 SkScalar cpuTime = histograms[BenchmarkControl::kNormalRecord][i].fCpuTi me;
398 recLine.appendf("%f ", cpuTime); 400 recLine.appendf("%f ", cpuTime);
399 avgRecord += cpuTime; 401 avgRecord += cpuTime;
400 cpuTime = histograms[BenchmarkControl::kRTreeRecord][i].fCpuTime; 402 cpuTime = histograms[BenchmarkControl::kRTreeRecord][i].fCpuTime;
401 recLine.appendf("%f", cpuTime); 403 recLine.appendf("%f", cpuTime);
402 avgRecordRTree += cpuTime; 404 avgRecordRTree += cpuTime;
405 avgPlaybackRTree += cpuTime;
403 406
404 // ==== Write playback info 407 // ==== Write playback info
405 pbLine.printf("%d ", i); 408 pbLine.printf("%d ", i);
406 pbLine.appendf("%f ", histograms[2][i].fCpuTime); // Start with normal playback time. 409 pbLine.appendf("%f ", histograms[2][i].fCpuTime); // Start with normal playback time.
410 avgPlayback += histograms[kNumBbhPlaybackBenchmarks - 1][i].fCpuTime;
411 avgPlaybackRTree += histograms[kNumBbhPlaybackBenchmarks][i].fCpuTime;
407 // Append all playback benchmark times. 412 // Append all playback benchmark times.
408 for (size_t j = kNumBbhPlaybackBenchmarks; j < kNumBenchmarks; ++j) { 413 for (size_t j = kNumBbhPlaybackBenchmarks; j < kNumBenchmarks; ++j) {
409 pbLine.appendf("%f ", histograms[j][i].fCpuTime); 414 pbLine.appendf("%f ", histograms[j][i].fCpuTime);
410 } 415 }
411 pbLine.remove(pbLine.size() - 1, 1); // Remove trailing space from line . 416 pbLine.remove(pbLine.size() - 1, 1); // Remove trailing space from line .
412 pbLine.appendf("\n"); 417 pbLine.appendf("\n");
413 recLine.appendf("\n"); 418 recLine.appendf("\n");
414 playbackOut.writeText(pbLine.c_str()); 419 playbackOut.writeText(pbLine.c_str());
415 recordOut.writeText(recLine.c_str()); 420 recordOut.writeText(recLine.c_str());
416 } 421 }
417 avgRecord /= argc - 1; 422 avgRecord /= argc - 1;
418 avgRecordRTree /= argc - 1; 423 avgRecordRTree /= argc - 1;
424 avgPlayback /= argc - 1;
425 avgPlaybackRTree /= argc - 1;
419 SkDebugf("Average base recording time: %.3fms\n", avgRecord); 426 SkDebugf("Average base recording time: %.3fms\n", avgRecord);
420 SkDebugf("Average recording time with rtree: %.3fms\n", avgRecordRTree); 427 SkDebugf("Average recording time with rtree: %.3fms\n", avgRecordRTree);
428 SkDebugf("Average base playback time: %.3fms\n", avgPlayback);
429 SkDebugf("Average playback time with rtree: %.3fms\n", avgPlaybackRTree);
430
421 SkDebugf("\nWrote data to gnuplot-readable files: %s %s\n", pbTitle, recTitl e); 431 SkDebugf("\nWrote data to gnuplot-readable files: %s %s\n", pbTitle, recTitl e);
422 432
423 return 0; 433 return 0;
424 } 434 }
425 435
426 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 436 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
427 int main(int argc, char** argv) { 437 int main(int argc, char** argv) {
428 return tool_main(argc, argv); 438 return tool_main(argc, argv);
429 } 439 }
430 #endif 440 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698