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

Side by Side Diff: tools/bench_pictures_main.cpp

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