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

Side by Side Diff: tools/bench_pictures_main.cpp

Issue 306483010: Revert of PictureBenchmark JSON logging (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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
« no previous file with comments | « tools/PictureResultsWriter.h ('k') | 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 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 "BenchTimer.h" 8 #include "BenchTimer.h"
9 #include "CopyTilesRenderer.h" 9 #include "CopyTilesRenderer.h"
10 #include "LazyDecodeBitmap.h" 10 #include "LazyDecodeBitmap.h"
11 #include "PictureBenchmark.h" 11 #include "PictureBenchmark.h"
12 #include "PictureRenderingFlags.h" 12 #include "PictureRenderingFlags.h"
13 #include "SkBenchLogger.h" 13 #include "SkBenchLogger.h"
14 #include "SkCommandLineFlags.h" 14 #include "SkCommandLineFlags.h"
15 #include "SkData.h"
16 #include "SkDiscardableMemoryPool.h" 15 #include "SkDiscardableMemoryPool.h"
17 #include "SkGraphics.h" 16 #include "SkGraphics.h"
18 #include "SkImageDecoder.h" 17 #include "SkImageDecoder.h"
19 #include "SkMath.h" 18 #include "SkMath.h"
20 #include "SkOSFile.h" 19 #include "SkOSFile.h"
21 #include "SkPicture.h" 20 #include "SkPicture.h"
22 #include "SkStream.h" 21 #include "SkStream.h"
23 #include "picture_utils.h" 22 #include "picture_utils.h"
24 #include "PictureResultsWriter.h"
25 23
26 SkBenchLogger gLogger; 24 SkBenchLogger gLogger;
27 PictureResultsLoggerWriter gLogWriter(&gLogger);
28 PictureResultsMultiWriter gWriter;
29 25
30 // Flags used by this file, in alphabetical order. 26 // Flags used by this file, in alphabetical order.
31 DEFINE_bool(countRAM, false, "Count the RAM used for bitmap pixels in each skp f ile"); 27 DEFINE_bool(countRAM, false, "Count the RAM used for bitmap pixels in each skp f ile");
32 DECLARE_bool(deferImageDecoding); 28 DECLARE_bool(deferImageDecoding);
33 DEFINE_string(filter, "", 29 DEFINE_string(filter, "",
34 "type:flag : Enable canvas filtering to disable a paint flag, " 30 "type:flag : Enable canvas filtering to disable a paint flag, "
35 "use no blur or low quality blur, or use no hinting or " 31 "use no blur or low quality blur, or use no hinting or "
36 "slight hinting. For all flags except AAClip, specify the " 32 "slight hinting. For all flags except AAClip, specify the "
37 "type of primitive to effect, or choose all. for AAClip " 33 "type of primitive to effect, or choose all. for AAClip "
38 "alone, the filter affects all clips independent of type. " 34 "alone, the filter affects all clips independent of type. "
39 "Specific flags are listed above."); 35 "Specific flags are listed above.");
40 DEFINE_string(logFile, "", "Destination for writing log output, in addition to s tdout."); 36 DEFINE_string(logFile, "", "Destination for writing log output, in addition to s tdout.");
41 DEFINE_bool(logPerIter, false, "Log each repeat timer instead of mean."); 37 DEFINE_bool(logPerIter, false, "Log each repeat timer instead of mean.");
42 #ifdef SK_BUILD_JSON_WRITER
43 DEFINE_string(jsonLog, "", "Destination for writing JSON data.");
44 #endif
45 DEFINE_bool(min, false, "Print the minimum times (instead of average)."); 38 DEFINE_bool(min, false, "Print the minimum times (instead of average).");
46 DECLARE_int32(multi); 39 DECLARE_int32(multi);
47 DECLARE_string(readPath); 40 DECLARE_string(readPath);
48 DEFINE_int32(repeat, 1, "Set the number of times to repeat each test."); 41 DEFINE_int32(repeat, 1, "Set the number of times to repeat each test.");
49 DEFINE_bool(timeIndividualTiles, false, "Report times for drawing individual til es, rather than " 42 DEFINE_bool(timeIndividualTiles, false, "Report times for drawing individual til es, rather than "
50 "times for drawing the whole page. Requires tiled rendering."); 43 "times for drawing the whole page. Requires tiled rendering.");
51 DEFINE_bool(purgeDecodedTex, false, "Purge decoded and GPU-uploaded textures " 44 DEFINE_bool(purgeDecodedTex, false, "Purge decoded and GPU-uploaded textures "
52 "after each iteration."); 45 "after each iteration.");
53 DEFINE_string(timers, "c", "[wcgWC]*: Display wall, cpu, gpu, truncated wall or truncated cpu time" 46 DEFINE_string(timers, "c", "[wcgWC]*: Display wall, cpu, gpu, truncated wall or truncated cpu time"
54 " for each picture."); 47 " for each picture.");
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 if (NULL == picture.get()) { 180 if (NULL == picture.get()) {
188 SkString err; 181 SkString err;
189 err.printf("Could not read an SkPicture from %s\n", inputPath.c_str()); 182 err.printf("Could not read an SkPicture from %s\n", inputPath.c_str());
190 gLogger.logError(err); 183 gLogger.logError(err);
191 return false; 184 return false;
192 } 185 }
193 186
194 SkString filename; 187 SkString filename;
195 sk_tools::get_basename(&filename, inputPath); 188 sk_tools::get_basename(&filename, inputPath);
196 189
197 gWriter.bench(filename.c_str(), picture->width(), picture->height()); 190 SkString result;
191 result.printf("running bench [%i %i] %s ", picture->width(), picture->height (),
192 filename.c_str());
193 gLogger.logProgress(result);
198 194
199 benchmark.run(picture); 195 benchmark.run(picture);
200 196
201 #if SK_LAZY_CACHE_STATS 197 #if SK_LAZY_CACHE_STATS
202 if (FLAGS_trackDeferredCaching) { 198 if (FLAGS_trackDeferredCaching) {
203 int cacheHits = pool->getCacheHits(); 199 int cacheHits = pool->getCacheHits();
204 int cacheMisses = pool->getCacheMisses(); 200 int cacheMisses = pool->getCacheMisses();
205 pool->resetCacheHitsAndMisses(); 201 pool->resetCacheHitsAndMisses();
206 SkString hitString; 202 SkString hitString;
207 hitString.printf("Cache hit rate: %f\n", (double) cacheHits / (cacheHits + cacheMisses)); 203 hitString.printf("Cache hit rate: %f\n", (double) cacheHits / (cacheHits + cacheMisses));
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 renderer->setDrawFilters(drawFilters, filtersName(drawFilters)); 353 renderer->setDrawFilters(drawFilters, filtersName(drawFilters));
358 if (FLAGS_logPerIter) { 354 if (FLAGS_logPerIter) {
359 benchmark->setTimerResultType(TimerData::kPerIter_Result); 355 benchmark->setTimerResultType(TimerData::kPerIter_Result);
360 } else if (FLAGS_min) { 356 } else if (FLAGS_min) {
361 benchmark->setTimerResultType(TimerData::kMin_Result); 357 benchmark->setTimerResultType(TimerData::kMin_Result);
362 } else { 358 } else {
363 benchmark->setTimerResultType(TimerData::kAvg_Result); 359 benchmark->setTimerResultType(TimerData::kAvg_Result);
364 } 360 }
365 benchmark->setRenderer(renderer); 361 benchmark->setRenderer(renderer);
366 benchmark->setRepeats(FLAGS_repeat); 362 benchmark->setRepeats(FLAGS_repeat);
367 benchmark->setWriter(&gWriter); 363 benchmark->setLogger(&gLogger);
368 } 364 }
369 365
370 static int process_input(const char* input, 366 static int process_input(const char* input,
371 sk_tools::PictureBenchmark& benchmark) { 367 sk_tools::PictureBenchmark& benchmark) {
372 SkString inputAsSkString(input); 368 SkString inputAsSkString(input);
373 SkOSFile::Iter iter(input, "skp"); 369 SkOSFile::Iter iter(input, "skp");
374 SkString inputFilename; 370 SkString inputFilename;
375 int failures = 0; 371 int failures = 0;
376 if (iter.next(&inputFilename)) { 372 if (iter.next(&inputFilename)) {
377 do { 373 do {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 SkString str; 410 SkString str;
415 str.printf("Could not open %s for writing.\n", FLAGS_logFile[0]); 411 str.printf("Could not open %s for writing.\n", FLAGS_logFile[0]);
416 gLogger.logError(str); 412 gLogger.logError(str);
417 // TODO(borenet): We're disabling this for now, due to 413 // TODO(borenet): We're disabling this for now, due to
418 // write-protected Android devices. The very short-term 414 // write-protected Android devices. The very short-term
419 // solution is to ignore the fact that we have no log file. 415 // solution is to ignore the fact that we have no log file.
420 //exit(-1); 416 //exit(-1);
421 } 417 }
422 } 418 }
423 419
424 #ifdef SK_BUILD_JSON_WRITER
425 SkAutoTDelete<PictureJSONResultsWriter> jsonWriter;
426 if (FLAGS_jsonLog.count() == 1) {
427 jsonWriter.reset(SkNEW(PictureJSONResultsWriter(FLAGS_jsonLog[0])));
428 gWriter.add(jsonWriter.get());
429 }
430
431 #endif
432 gWriter.add(&gLogWriter);
433
434 420
435 #if SK_ENABLE_INST_COUNT 421 #if SK_ENABLE_INST_COUNT
436 gPrintInstCount = true; 422 gPrintInstCount = true;
437 #endif 423 #endif
438 SkAutoGraphics ag; 424 SkAutoGraphics ag;
439 425
440 sk_tools::PictureBenchmark benchmark; 426 sk_tools::PictureBenchmark benchmark;
441 427
442 setup_benchmark(&benchmark); 428 setup_benchmark(&benchmark);
443 429
444 int failures = 0; 430 int failures = 0;
445 for (int i = 0; i < FLAGS_readPath.count(); ++i) { 431 for (int i = 0; i < FLAGS_readPath.count(); ++i) {
446 failures += process_input(FLAGS_readPath[i], benchmark); 432 failures += process_input(FLAGS_readPath[i], benchmark);
447 } 433 }
448 434
449 if (failures != 0) { 435 if (failures != 0) {
450 SkString err; 436 SkString err;
451 err.printf("Failed to run %i benchmarks.\n", failures); 437 err.printf("Failed to run %i benchmarks.\n", failures);
452 gLogger.logError(err); 438 gLogger.logError(err);
453 return 1; 439 return 1;
454 } 440 }
455 #if SK_LAZY_CACHE_STATS 441 #if SK_LAZY_CACHE_STATS
456 if (FLAGS_trackDeferredCaching) { 442 if (FLAGS_trackDeferredCaching) {
457 SkDebugf("Total cache hit rate: %f\n", 443 SkDebugf("Total cache hit rate: %f\n",
458 (double) gTotalCacheHits / (gTotalCacheHits + gTotalCacheMisses )); 444 (double) gTotalCacheHits / (gTotalCacheHits + gTotalCacheMisses ));
459 } 445 }
460 #endif 446 #endif
461 gWriter.end();
462 return 0; 447 return 0;
463 } 448 }
464 449
465 #if !defined SK_BUILD_FOR_IOS 450 #if !defined SK_BUILD_FOR_IOS
466 int main(int argc, char * const argv[]) { 451 int main(int argc, char * const argv[]) {
467 return tool_main(argc, (char**) argv); 452 return tool_main(argc, (char**) argv);
468 } 453 }
469 #endif 454 #endif
OLDNEW
« no previous file with comments | « tools/PictureResultsWriter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698