diff options
author | cdalton <cdalton@nvidia.com> | 2015-06-25 10:51:56 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-25 10:51:56 -0700 |
commit | b4022965a280dd1ed64d6103dd29e2189abe6e00 (patch) | |
tree | f7bea91cb929485d20f35c1edf19e9b0f3f57c64 /bench | |
parent | b0c5071a376ecfb608c49886f2c86b1ce40b1389 (diff) |
Add loopSKP flag to nanobench
Adds a loopSKP flag that forces SKPBenches to draw with only 1 loop.
BUG=skia:
Review URL: https://codereview.chromium.org/1203193002
Diffstat (limited to 'bench')
-rw-r--r-- | bench/Benchmark.h | 4 | ||||
-rw-r--r-- | bench/SKPAnimationBench.cpp | 6 | ||||
-rw-r--r-- | bench/SKPAnimationBench.h | 2 | ||||
-rw-r--r-- | bench/SKPBench.cpp | 6 | ||||
-rw-r--r-- | bench/SKPBench.h | 8 | ||||
-rw-r--r-- | bench/nanobench.cpp | 13 |
6 files changed, 26 insertions, 13 deletions
diff --git a/bench/Benchmark.h b/bench/Benchmark.h index 22b52ab4e8..30ceb88acb 100644 --- a/bench/Benchmark.h +++ b/bench/Benchmark.h @@ -65,6 +65,10 @@ public: return backend != kNonRendering_Backend; } + virtual int calculateLoops(int defaultLoops) const { + return defaultLoops; + } + // Call before draw, allows the benchmark to do setup work outside of the // timer. When a benchmark is repeatedly drawn, this should be called once // before the initial draw. diff --git a/bench/SKPAnimationBench.cpp b/bench/SKPAnimationBench.cpp index 24506d814f..55a85966a4 100644 --- a/bench/SKPAnimationBench.cpp +++ b/bench/SKPAnimationBench.cpp @@ -10,9 +10,9 @@ #include "SkMultiPictureDraw.h" #include "SkSurface.h" -SKPAnimationBench::SKPAnimationBench(const char* name, const SkPicture* pic, - const SkIRect& clip, SkMatrix animationMatrix, int steps) - : INHERITED(name, pic, clip, 1.0, false) +SKPAnimationBench::SKPAnimationBench(const char* name, const SkPicture* pic, const SkIRect& clip, + SkMatrix animationMatrix, int steps, bool doLooping) + : INHERITED(name, pic, clip, 1.0, false, doLooping) , fSteps(steps) , fAnimationMatrix(animationMatrix) , fName(name) { diff --git a/bench/SKPAnimationBench.h b/bench/SKPAnimationBench.h index f6e9fa4ede..65708f7639 100644 --- a/bench/SKPAnimationBench.h +++ b/bench/SKPAnimationBench.h @@ -17,7 +17,7 @@ class SKPAnimationBench : public SKPBench { public: SKPAnimationBench(const char* name, const SkPicture*, const SkIRect& devClip, - SkMatrix viewMatrix, int steps); + SkMatrix viewMatrix, int steps, bool doLooping); protected: const char* onGetName() override; diff --git a/bench/SKPBench.cpp b/bench/SKPBench.cpp index 757ee4655e..ef7f644dd7 100644 --- a/bench/SKPBench.cpp +++ b/bench/SKPBench.cpp @@ -18,12 +18,13 @@ DEFINE_int32(GPUbenchTileW, 1600, "Tile width used for GPU SKP playback."); DEFINE_int32(GPUbenchTileH, 512, "Tile height used for GPU SKP playback."); SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip, SkScalar scale, - bool useMultiPictureDraw) + bool useMultiPictureDraw, bool doLooping) : fPic(SkRef(pic)) , fClip(clip) , fScale(scale) , fName(name) - , fUseMultiPictureDraw(useMultiPictureDraw) { + , fUseMultiPictureDraw(useMultiPictureDraw) + , fDoLooping(doLooping) { fUniqueName.printf("%s_%.2g", name, scale); // Scale makes this unqiue for perf.skia.org traces. if (useMultiPictureDraw) { fUniqueName.append("_mpd"); @@ -104,6 +105,7 @@ SkIPoint SKPBench::onGetSize() { } void SKPBench::onDraw(const int loops, SkCanvas* canvas) { + SkASSERT(fDoLooping || 1 == loops); if (fUseMultiPictureDraw) { for (int i = 0; i < loops; i++) { this->drawMPDPicture(); diff --git a/bench/SKPBench.h b/bench/SKPBench.h index 3b645e9734..e1c66bf2ec 100644 --- a/bench/SKPBench.h +++ b/bench/SKPBench.h @@ -18,9 +18,13 @@ class SKPBench : public Benchmark { public: SKPBench(const char* name, const SkPicture*, const SkIRect& devClip, SkScalar scale, - bool useMultiPictureDraw); + bool useMultiPictureDraw, bool doLooping); ~SKPBench() override; + int calculateLoops(int defaultLoops) const override { + return fDoLooping ? defaultLoops : 1; + } + protected: const char* onGetName() override; const char* onGetUniqueName() override; @@ -48,6 +52,8 @@ private: SkTDArray<SkSurface*> fSurfaces; // for MultiPictureDraw SkTDArray<SkIRect> fTileRects; // for MultiPictureDraw + const bool fDoLooping; + typedef Benchmark INHERITED; }; diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp index 13ae9f6239..9f3887bc20 100644 --- a/bench/nanobench.cpp +++ b/bench/nanobench.cpp @@ -92,6 +92,7 @@ DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); DEFINE_string(zoom, "1.0,1", "Comma-separated scale,step zoom factors for SKPs."); DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); +DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test."); DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); @@ -272,7 +273,8 @@ static int cpu_bench(const double overhead, Target* target, Benchmark* bench, do // First figure out approximately how many loops of bench it takes to make overhead negligible. double bench_plus_overhead = 0.0; int round = 0; - if (kAutoTuneLoops == FLAGS_loops) { + int loops = bench->calculateLoops(FLAGS_loops); + if (kAutoTuneLoops == loops) { while (bench_plus_overhead < overhead) { if (round++ == FLAGS_maxCalibrationAttempts) { SkDebugf("WARNING: Can't estimate loops for %s (%s vs. %s); skipping.\n", @@ -299,7 +301,6 @@ static int cpu_bench(const double overhead, Target* target, Benchmark* bench, do // bench_plus_overhead - overhead) // // Luckily, this also works well in practice. :) - int loops = FLAGS_loops; if (kAutoTuneLoops == loops) { const double numer = overhead / FLAGS_overheadGoal - overhead; const double denom = bench_plus_overhead - overhead; @@ -320,7 +321,7 @@ static int gpu_bench(Target* target, double* samples, int maxGpuFrameLag) { // First, figure out how many loops it'll take to get a frame up to FLAGS_gpuMs. - int loops = FLAGS_loops; + int loops = bench->calculateLoops(FLAGS_loops); if (kAutoTuneLoops == loops) { loops = 1; double elapsed = 0; @@ -715,8 +716,8 @@ public: fSourceType = "skp"; fBenchType = "playback"; return SkNEW_ARGS(SKPBench, - (name.c_str(), pic.get(), fClip, - fScales[fCurrentScale], fUseMPDs[fCurrentUseMPD++])); + (name.c_str(), pic.get(), fClip, fScales[fCurrentScale], + fUseMPDs[fCurrentUseMPD++], FLAGS_loopSKP)); } fCurrentUseMPD = 0; @@ -741,7 +742,7 @@ public: SkMatrix anim = SkMatrix::I(); anim.setScale(fZoomScale, fZoomScale); return SkNEW_ARGS(SKPAnimationBench, (name.c_str(), pic.get(), fClip, anim, - fZoomSteps)); + fZoomSteps, FLAGS_loopSKP)); } } |