| 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 "nanobench.h" | 10 #include "nanobench.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 "function that ping-pongs between 1.0 and zoomMax."
); | 105 "function that ping-pongs between 1.0 and zoomMax."
); |
| 106 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); | 106 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); |
| 107 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); | 107 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); |
| 108 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); | 108 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); |
| 109 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); | 109 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); |
| 110 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test
."); | 110 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test
."); |
| 111 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); | 111 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); |
| 112 DEFINE_bool(gpuStatsDump, false, "Dump GPU states after each benchmark to json")
; | 112 DEFINE_bool(gpuStatsDump, false, "Dump GPU states after each benchmark to json")
; |
| 113 DEFINE_bool(keepAlive, false, "Print a message every so often so that we don't t
ime out"); | 113 DEFINE_bool(keepAlive, false, "Print a message every so often so that we don't t
ime out"); |
| 114 | 114 |
| 115 DEFINE_string(sourceType, "", |
| 116 "Apply usual --match rules to source type: bench, gm, skp, image, etc.")
; |
| 117 DEFINE_string(benchType, "", |
| 118 "Apply usual --match rules to bench type: micro, recording, playback, sk
codec, etc."); |
| 119 |
| 115 static double now_ms() { return SkTime::GetNSecs() * 1e-6; } | 120 static double now_ms() { return SkTime::GetNSecs() * 1e-6; } |
| 116 | 121 |
| 117 static SkString humanize(double ms) { | 122 static SkString humanize(double ms) { |
| 118 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); | 123 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); |
| 119 return HumanizeMs(ms); | 124 return HumanizeMs(ms); |
| 120 } | 125 } |
| 121 #define HUMANIZE(ms) humanize(ms).c_str() | 126 #define HUMANIZE(ms) humanize(ms).c_str() |
| 122 | 127 |
| 123 bool Target::init(SkImageInfo info, Benchmark* bench) { | 128 bool Target::init(SkImageInfo info, Benchmark* bench) { |
| 124 if (Benchmark::kRaster_Backend == config.backend) { | 129 if (Benchmark::kRaster_Backend == config.backend) { |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 | 626 |
| 622 pic->reset(SkPicture::CreateFromStream(stream.get())); | 627 pic->reset(SkPicture::CreateFromStream(stream.get())); |
| 623 if (pic->get() == nullptr) { | 628 if (pic->get() == nullptr) { |
| 624 SkDebugf("Could not read %s as an SkPicture.\n", path); | 629 SkDebugf("Could not read %s as an SkPicture.\n", path); |
| 625 return false; | 630 return false; |
| 626 } | 631 } |
| 627 return true; | 632 return true; |
| 628 } | 633 } |
| 629 | 634 |
| 630 Benchmark* next() { | 635 Benchmark* next() { |
| 636 SkAutoTDelete<Benchmark> bench; |
| 637 do { |
| 638 bench.reset(this->rawNext()); |
| 639 if (!bench) { |
| 640 return nullptr; |
| 641 } |
| 642 } while(SkCommandLineFlags::ShouldSkip(FLAGS_sourceType, fSourceType) || |
| 643 SkCommandLineFlags::ShouldSkip(FLAGS_benchType, fBenchType)); |
| 644 return bench.detach(); |
| 645 } |
| 646 |
| 647 Benchmark* rawNext() { |
| 631 if (fBenches) { | 648 if (fBenches) { |
| 632 Benchmark* bench = fBenches->factory()(nullptr); | 649 Benchmark* bench = fBenches->factory()(nullptr); |
| 633 fBenches = fBenches->next(); | 650 fBenches = fBenches->next(); |
| 634 fSourceType = "bench"; | 651 fSourceType = "bench"; |
| 635 fBenchType = "micro"; | 652 fBenchType = "micro"; |
| 636 return bench; | 653 return bench; |
| 637 } | 654 } |
| 638 | 655 |
| 639 while (fGMs) { | 656 while (fGMs) { |
| 640 SkAutoTDelete<skiagm::GM> gm(fGMs->factory()(nullptr)); | 657 SkAutoTDelete<skiagm::GM> gm(fGMs->factory()(nullptr)); |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 | 1233 |
| 1217 return 0; | 1234 return 0; |
| 1218 } | 1235 } |
| 1219 | 1236 |
| 1220 #if !defined SK_BUILD_FOR_IOS | 1237 #if !defined SK_BUILD_FOR_IOS |
| 1221 int main(int argc, char** argv) { | 1238 int main(int argc, char** argv) { |
| 1222 SkCommandLineFlags::Parse(argc, argv); | 1239 SkCommandLineFlags::Parse(argc, argv); |
| 1223 return nanobench_main(); | 1240 return nanobench_main(); |
| 1224 } | 1241 } |
| 1225 #endif | 1242 #endif |
| OLD | NEW |