From c289743864e2ab926a95e617a5cd1d29b26d1825 Mon Sep 17 00:00:00 2001 From: "mtklein@google.com" Date: Tue, 10 Sep 2013 19:23:38 +0000 Subject: Major bench refactoring. - Use FLAGS_. - Remove outer repeat loop. - Tune inner loop automatically. BUG=skia:1590 R=epoger@google.com, scroggo@google.com Review URL: https://codereview.chromium.org/23478013 git-svn-id: http://skia.googlecode.com/svn/trunk@11187 2bbb7eff-a529-9590-31e7-b0007b416f81 --- bench/DashBench.cpp | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'bench/DashBench.cpp') diff --git a/bench/DashBench.cpp b/bench/DashBench.cpp index 0fcde316b9..84fe3ab752 100644 --- a/bench/DashBench.cpp +++ b/bench/DashBench.cpp @@ -37,9 +37,6 @@ protected: SkPoint fPts[2]; bool fDoClip; - enum { - N = SkBENCHLOOP(100) - }; public: DashBench(void* param, const SkScalar intervals[], int count, int width, bool doClip = false) : INHERITED(param) { @@ -85,7 +82,7 @@ protected: canvas->clipRect(r); } - this->handlePath(canvas, path, paint, N); + this->handlePath(canvas, path, paint, this->getLoops()); } virtual void handlePath(SkCanvas* canvas, const SkPath& path, @@ -183,10 +180,6 @@ class MakeDashBench : public SkBenchmark { SkPath fPath; SkAutoTUnref fPE; - enum { - N = SkBENCHLOOP(400) - }; - public: MakeDashBench(void* param, void (*proc)(SkPath*), const char name[]) : INHERITED(param) { fName.printf("makedash_%s", name); @@ -203,7 +196,7 @@ protected: virtual void onDraw(SkCanvas*) SK_OVERRIDE { SkPath dst; - for (int i = 0; i < N; ++i) { + for (int i = 0; i < this->getLoops(); ++i) { SkStrokeRec rec(SkStrokeRec::kHairline_InitStyle); fPE->filterPath(&dst, fPath, &rec, NULL); @@ -224,10 +217,6 @@ class DashLineBench : public SkBenchmark { bool fIsRound; SkAutoTUnref fPE; - enum { - N = SkBENCHLOOP(200) - }; - public: DashLineBench(void* param, SkScalar width, bool isRound) : INHERITED(param) { fName.printf("dashline_%g_%s", SkScalarToFloat(width), isRound ? "circle" : "square"); @@ -249,7 +238,7 @@ protected: paint.setStrokeWidth(fStrokeWidth); paint.setStrokeCap(fIsRound ? SkPaint::kRound_Cap : SkPaint::kSquare_Cap); paint.setPathEffect(fPE); - for (int i = 0; i < N; ++i) { + for (int i = 0; i < this->getLoops(); ++i) { canvas->drawLine(10 * SK_Scalar1, 10 * SK_Scalar1, 640 * SK_Scalar1, 10 * SK_Scalar1, paint); } @@ -266,10 +255,6 @@ class DrawPointsDashingBench : public SkBenchmark { SkAutoTUnref fPathEffect; - enum { - N = SkBENCHLOOP(480) - }; - public: DrawPointsDashingBench(void* param, int dashLength, int strokeWidth, bool doAA) : INHERITED(param) { @@ -287,7 +272,6 @@ protected: } virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { - SkPaint p; this->setupPaint(&p); p.setColor(SK_ColorBLACK); @@ -301,8 +285,7 @@ protected: { SkIntToScalar(640), 0 } }; - for (int i = 0; i < N; ++i) { - + for (int i = 0; i < this->getLoops(); ++i) { pts[0].fY = pts[1].fY = SkIntToScalar(i % 480); canvas->drawPoints(SkCanvas::kLines_PointMode, 2, pts, p); } @@ -381,7 +364,9 @@ protected: p.setStrokeWidth(fStrokeWidth); p.setPathEffect(fPathEffect); - canvas->drawPoints(SkCanvas::kLines_PointMode, 2, fPts, p); + for (int i = 0; i < this->getLoops(); i++) { + canvas->drawPoints(SkCanvas::kLines_PointMode, 2, fPts, p); + } } private: -- cgit v1.2.3