Chromium Code Reviews| Index: bench/nanobench.cpp |
| diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp |
| index 1f5ae60f822ab9d28b84c37b37465398544616b5..3dbda392410949713df3ada376e357dc2da068c2 100644 |
| --- a/bench/nanobench.cpp |
| +++ b/bench/nanobench.cpp |
| @@ -70,6 +70,7 @@ DEFINE_int32(maxLoops, 1000000, "Never run a bench more times than this."); |
| DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs."); |
| DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); |
| DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); |
|
mtklein
2014/11/19 19:12:37
Seems like bbh and mpd don't really need to be fla
robertphillips
2014/11/19 19:58:58
I was mainly following the pattern. It does seem l
|
| +DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); |
| DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); |
| static SkString humanize(double ms) { |
| @@ -437,7 +438,8 @@ public: |
| , fGMs(skiagm::GMRegistry::Head()) |
| , fCurrentRecording(0) |
| , fCurrentScale(0) |
| - , fCurrentSKP(0) { |
| + , fCurrentSKP(0) |
| + , fCurrentUseMPD(0) { |
| for (int i = 0; i < FLAGS_skps.count(); i++) { |
| if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { |
| fSKPs.push_back() = FLAGS_skps[i]; |
| @@ -462,6 +464,11 @@ public: |
| exit(1); |
| } |
| } |
| + |
| + fUseMPDs.push_back() = false; |
| + if (FLAGS_mpd) { |
| + fUseMPDs.push_back() = true; |
| + } |
| } |
| static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic) { |
| @@ -520,25 +527,31 @@ public: |
| // Then once each for each scale as SKPBenches (playback). |
| while (fCurrentScale < fScales.count()) { |
| while (fCurrentSKP < fSKPs.count()) { |
| - const SkString& path = fSKPs[fCurrentSKP++]; |
| - SkAutoTUnref<SkPicture> pic; |
| - if (!ReadPicture(path.c_str(), &pic)) { |
| - continue; |
| - } |
| - if (FLAGS_bbh) { |
| - // The SKP we read off disk doesn't have a BBH. Re-record so it grows one. |
| - SkRTreeFactory factory; |
| - SkPictureRecorder recorder; |
| - pic->playback(recorder.beginRecording(pic->cullRect().width(), |
| - pic->cullRect().height(), |
| - &factory)); |
| - pic.reset(recorder.endRecording()); |
| + while (fCurrentUseMPD < fUseMPDs.count()) { |
|
mtklein
2014/11/19 19:12:37
I seem to be falling into an infinite loop when I
robertphillips
2014/11/19 19:58:58
Done.
|
| + const SkString& path = fSKPs[fCurrentSKP]; |
| + SkAutoTUnref<SkPicture> pic; |
| + if (!ReadPicture(path.c_str(), &pic)) { |
| + continue; |
| + } |
| + if (FLAGS_bbh) { |
| + // The SKP we read off disk doesn't have a BBH. Re-record so it grows one. |
| + SkRTreeFactory factory; |
| + SkPictureRecorder recorder; |
| + static const int kFlags = SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag; |
| + pic->playback(recorder.beginRecording(pic->cullRect().width(), |
| + pic->cullRect().height(), |
| + &factory, kFlags)); |
| + pic.reset(recorder.endRecording()); |
| + } |
| + SkString name = SkOSPath::Basename(path.c_str()); |
| + fSourceType = "skp"; |
| + fBenchType = "playback"; |
| + return SkNEW_ARGS(SKPBench, |
| + (name.c_str(), pic.get(), fClip, |
| + fScales[fCurrentScale], fUseMPDs[fCurrentUseMPD++])); |
| } |
| - SkString name = SkOSPath::Basename(path.c_str()); |
| - fSourceType = "skp"; |
| - fBenchType = "playback"; |
| - return SkNEW_ARGS(SKPBench, |
| - (name.c_str(), pic.get(), fClip, fScales[fCurrentScale])); |
| + fCurrentUseMPD = 0; |
| + fCurrentSKP++; |
| } |
| fCurrentSKP = 0; |
| fCurrentScale++; |
| @@ -555,6 +568,7 @@ public: |
| SkStringPrintf("%d %d %d %d", fClip.fLeft, fClip.fTop, |
| fClip.fRight, fClip.fBottom).c_str()); |
| log->configOption("scale", SkStringPrintf("%.2g", fScales[fCurrentScale]).c_str()); |
| + log->configOption("multi_picture_draw", fUseMPDs[fCurrentUseMPD-1] ? "true" : "false"); |
| } |
| } |
| @@ -564,12 +578,14 @@ private: |
| SkIRect fClip; |
| SkTArray<SkScalar> fScales; |
| SkTArray<SkString> fSKPs; |
| + SkTArray<bool> fUseMPDs; |
| const char* fSourceType; // What we're benching: bench, GM, SKP, ... |
| const char* fBenchType; // How we bench it: micro, recording, playback, ... |
| int fCurrentRecording; |
| int fCurrentScale; |
| int fCurrentSKP; |
| + int fCurrentUseMPD; |
| }; |
| int nanobench_main(); |
| @@ -659,6 +675,8 @@ int nanobench_main() { |
| SkCanvas* canvas = targets[j]->surface.get() ? targets[j]->surface->getCanvas() : NULL; |
| const char* config = targets[j]->config.name; |
| + bench->perCanvasPreDraw(canvas); |
| + |
| const int loops = |
| #if SK_SUPPORT_GPU |
| Benchmark::kGPU_Backend == targets[j]->config.backend |
| @@ -667,6 +685,8 @@ int nanobench_main() { |
| #endif |
| cpu_bench( overhead, bench.get(), canvas, samples.get()); |
| + bench->perCanvasPostDraw(canvas); |
| + |
| if (canvas && !FLAGS_writePath.isEmpty() && FLAGS_writePath[0]) { |
| SkString pngFilename = SkOSPath::Join(FLAGS_writePath[0], config); |
| pngFilename = SkOSPath::Join(pngFilename.c_str(), bench->getUniqueName()); |