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
diff --git a/bench/SkBenchmark.h b/bench/SkBenchmark.h
index 7ebe104..343bde2 100644
--- a/bench/SkBenchmark.h
+++ b/bench/SkBenchmark.h
@@ -10,7 +10,6 @@
#include "SkRefCnt.h"
#include "SkPoint.h"
-#include "SkTDict.h"
#include "SkTRegistry.h"
#define DEF_BENCH(code) \
@@ -27,12 +26,6 @@
*/
-#ifdef SK_DEBUG
- #define SkBENCHLOOP(n) 1
-#else
- #define SkBENCHLOOP(n) n
-#endif
-
class SkCanvas;
class SkPaint;
@@ -43,6 +36,7 @@
kTrue,
kFalse
};
+ static const char* Name[];
};
class SkBenchmark : public SkRefCnt {
@@ -82,19 +76,6 @@
fDither = state;
}
- void setStrokeWidth(SkScalar width) {
- strokeWidth = width;
- fHasStrokeWidth = true;
- }
-
- SkScalar getStrokeWidth() {
- return strokeWidth;
- }
-
- bool hasStrokeWidth() {
- return fHasStrokeWidth;
- }
-
/** If true; the benchmark does rendering; if false, the benchmark
doesn't, and so need not be re-run in every different rendering
mode. */
@@ -102,10 +83,6 @@
return fIsRendering;
}
- const char* findDefine(const char* key) const;
- bool findDefine32(const char* key, int32_t* value) const;
- bool findDefineScalar(const char* key, SkScalar* value) const;
-
/** Assign masks for paint-flags. These will be applied when setupPaint()
* is called.
*
@@ -120,7 +97,14 @@
fClearMask = clearMask;
}
- float getDurationScale() { return this->onGetDurationScale(); }
+ // The bench framework calls this to control the runtime of a bench.
+ void setLoops(int loops) {
+ fLoops = loops;
+ }
+
+ // Each bench should do its main work in a loop like this:
+ // for (int i = 0; i < this->getLoops(); i++) { <work here> }
+ int getLoops() const { return fLoops; }
protected:
virtual void setupPaint(SkPaint* paint);
@@ -129,27 +113,18 @@
virtual void onPreDraw() {}
virtual void onDraw(SkCanvas*) = 0;
virtual void onPostDraw() {}
- // the caller will scale the computed duration by this value. It allows a
- // slow bench to run fewer inner loops, but return the corresponding scale
- // so that its reported duration can be compared against other benches.
- // e.g.
- // if I run 10x slower, I can run 1/10 the number of inner-loops, but
- // return 10.0 for my durationScale, so I "report" the honest duration.
- virtual float onGetDurationScale() { return 1; }
virtual SkIPoint onGetSize();
/// Defaults to true.
bool fIsRendering;
private:
- const SkTDict<const char*>* fDict;
int fForceAlpha;
bool fForceAA;
bool fForceFilter;
SkTriState::State fDither;
- bool fHasStrokeWidth;
- SkScalar strokeWidth;
uint32_t fOrMask, fClearMask;
+ int fLoops;
typedef SkRefCnt INHERITED;
};