| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 <ctype.h> | 8 #include <ctype.h> |
| 9 | 9 |
| 10 #include "Benchmark.h" | 10 #include "Benchmark.h" |
| 11 #include "CrashHandler.h" | 11 #include "CrashHandler.h" |
| 12 #include "GMBench.h" | 12 #include "GMBench.h" |
| 13 #include "ProcStats.h" | 13 #include "ProcStats.h" |
| 14 #include "ResultsWriter.h" | 14 #include "ResultsWriter.h" |
| 15 #include "RecordingBench.h" | 15 #include "RecordingBench.h" |
| 16 #include "SKPBench.h" | 16 #include "SKPBench.h" |
| 17 #include "Stats.h" | 17 #include "Stats.h" |
| 18 #include "Timer.h" | 18 #include "Timer.h" |
| 19 | 19 |
| 20 #include "SkBBHFactory.h" | 20 #include "SkBBoxHierarchy.h" |
| 21 #include "SkCanvas.h" | 21 #include "SkCanvas.h" |
| 22 #include "SkCommonFlags.h" | 22 #include "SkCommonFlags.h" |
| 23 #include "SkForceLinking.h" | 23 #include "SkForceLinking.h" |
| 24 #include "SkGraphics.h" | 24 #include "SkGraphics.h" |
| 25 #include "SkOSFile.h" | 25 #include "SkOSFile.h" |
| 26 #include "SkPictureRecorder.h" | 26 #include "SkPictureRecorder.h" |
| 27 #include "SkString.h" | 27 #include "SkString.h" |
| 28 #include "SkSurface.h" | 28 #include "SkSurface.h" |
| 29 | 29 |
| 30 #if SK_SUPPORT_GPU | 30 #if SK_SUPPORT_GPU |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 DEFINE_bool(gpuCompressAlphaMasks, false, "Compress masks generated from falling
back to " | 63 DEFINE_bool(gpuCompressAlphaMasks, false, "Compress masks generated from falling
back to " |
| 64 "software path rendering."); | 64 "software path rendering."); |
| 65 | 65 |
| 66 DEFINE_string(outResultsFile, "", "If given, write results here as JSON."); | 66 DEFINE_string(outResultsFile, "", "If given, write results here as JSON."); |
| 67 DEFINE_int32(maxCalibrationAttempts, 3, | 67 DEFINE_int32(maxCalibrationAttempts, 3, |
| 68 "Try up to this many times to guess loops for a bench, or skip the
bench."); | 68 "Try up to this many times to guess loops for a bench, or skip the
bench."); |
| 69 DEFINE_int32(maxLoops, 1000000, "Never run a bench more times than this."); | 69 DEFINE_int32(maxLoops, 1000000, "Never run a bench more times than this."); |
| 70 DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs."); | 70 DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs."); |
| 71 DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); | 71 DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); |
| 72 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); | 72 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); |
| 73 DEFINE_int32(benchTile, 256, "Tile dimension used for SKP playback."); | |
| 74 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); | 73 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); |
| 75 | 74 |
| 76 static SkString humanize(double ms) { | 75 static SkString humanize(double ms) { |
| 77 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); | 76 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); |
| 78 if (ms > 1e+3) return SkStringPrintf("%.3gs", ms/1e3); | 77 if (ms > 1e+3) return SkStringPrintf("%.3gs", ms/1e3); |
| 79 if (ms < 1e-3) return SkStringPrintf("%.3gns", ms*1e6); | 78 if (ms < 1e-3) return SkStringPrintf("%.3gns", ms*1e6); |
| 80 #ifdef SK_BUILD_FOR_WIN | 79 #ifdef SK_BUILD_FOR_WIN |
| 81 if (ms < 1) return SkStringPrintf("%.3gus", ms*1e3); | 80 if (ms < 1) return SkStringPrintf("%.3gus", ms*1e3); |
| 82 #else | 81 #else |
| 83 if (ms < 1) return SkStringPrintf("%.3gµs", ms*1e3); | 82 if (ms < 1) return SkStringPrintf("%.3gµs", ms*1e3); |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 // Then once each for each scale as SKPBenches (playback). | 507 // Then once each for each scale as SKPBenches (playback). |
| 509 while (fCurrentScale < fScales.count()) { | 508 while (fCurrentScale < fScales.count()) { |
| 510 while (fCurrentSKP < fSKPs.count()) { | 509 while (fCurrentSKP < fSKPs.count()) { |
| 511 const SkString& path = fSKPs[fCurrentSKP++]; | 510 const SkString& path = fSKPs[fCurrentSKP++]; |
| 512 SkAutoTUnref<SkPicture> pic; | 511 SkAutoTUnref<SkPicture> pic; |
| 513 if (!ReadPicture(path.c_str(), &pic)) { | 512 if (!ReadPicture(path.c_str(), &pic)) { |
| 514 continue; | 513 continue; |
| 515 } | 514 } |
| 516 if (FLAGS_bbh) { | 515 if (FLAGS_bbh) { |
| 517 // The SKP we read off disk doesn't have a BBH. Re-record s
o it grows one. | 516 // The SKP we read off disk doesn't have a BBH. Re-record s
o it grows one. |
| 518 const SkTileGridFactory::TileGridInfo info = { | 517 SkRTreeFactory factory; |
| 519 SkISize::Make(FLAGS_benchTile, FLAGS_benchTile), // til
e interval | |
| 520 SkISize::Make(0,0), // mar
gin | |
| 521 SkIPoint::Make(0,0), // off
set | |
| 522 }; | |
| 523 SkTileGridFactory factory(info); | |
| 524 SkPictureRecorder recorder; | 518 SkPictureRecorder recorder; |
| 525 pic->playback(recorder.beginRecording(pic->cullRect().width(
), | 519 pic->playback(recorder.beginRecording(pic->cullRect().width(
), |
| 526 pic->cullRect().height
(), | 520 pic->cullRect().height
(), |
| 527 &factory)); | 521 &factory)); |
| 528 pic.reset(recorder.endRecording()); | 522 pic.reset(recorder.endRecording()); |
| 529 } | 523 } |
| 530 SkString name = SkOSPath::Basename(path.c_str()); | 524 SkString name = SkOSPath::Basename(path.c_str()); |
| 531 fSourceType = "skp"; | 525 fSourceType = "skp"; |
| 532 fBenchType = "playback"; | 526 fBenchType = "playback"; |
| 533 return SkNEW_ARGS(SKPBench, | 527 return SkNEW_ARGS(SKPBench, |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 , HUMANIZE(stats.max) | 713 , HUMANIZE(stats.max) |
| 720 , stddev_percent | 714 , stddev_percent |
| 721 , stats.plot.c_str() | 715 , stats.plot.c_str() |
| 722 , config | 716 , config |
| 723 , bench->getUniqueName() | 717 , bench->getUniqueName() |
| 724 ); | 718 ); |
| 725 } | 719 } |
| 726 #if SK_SUPPORT_GPU && GR_CACHE_STATS | 720 #if SK_SUPPORT_GPU && GR_CACHE_STATS |
| 727 if (FLAGS_veryVerbose && | 721 if (FLAGS_veryVerbose && |
| 728 Benchmark::kGPU_Backend == targets[j]->config.backend) { | 722 Benchmark::kGPU_Backend == targets[j]->config.backend) { |
| 729 gGrFactory->get(targets[j]->config.ctxType)->printCacheStats();
| 723 gGrFactory->get(targets[j]->config.ctxType)->printCacheStats(); |
| 730 } | 724 } |
| 731 #endif | 725 #endif |
| 732 } | 726 } |
| 733 targets.deleteAll(); | 727 targets.deleteAll(); |
| 734 | 728 |
| 735 #if SK_SUPPORT_GPU | 729 #if SK_SUPPORT_GPU |
| 736 if (FLAGS_abandonGpuContext) { | 730 if (FLAGS_abandonGpuContext) { |
| 737 gGrFactory->abandonContexts(); | 731 gGrFactory->abandonContexts(); |
| 738 } | 732 } |
| 739 if (FLAGS_resetGpuContext || FLAGS_abandonGpuContext) { | 733 if (FLAGS_resetGpuContext || FLAGS_abandonGpuContext) { |
| 740 gGrFactory->destroyContexts(); | 734 gGrFactory->destroyContexts(); |
| 741 } | 735 } |
| 742 #endif | 736 #endif |
| 743 } | 737 } |
| 744 | 738 |
| 745 return 0; | 739 return 0; |
| 746 } | 740 } |
| 747 | 741 |
| 748 #if !defined SK_BUILD_FOR_IOS | 742 #if !defined SK_BUILD_FOR_IOS |
| 749 int main(int argc, char** argv) { | 743 int main(int argc, char** argv) { |
| 750 SkCommandLineFlags::Parse(argc, argv); | 744 SkCommandLineFlags::Parse(argc, argv); |
| 751 return nanobench_main(); | 745 return nanobench_main(); |
| 752 } | 746 } |
| 753 #endif | 747 #endif |
| OLD | NEW |