Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4194)

Unified Diff: bench/SkBenchmark.h

Issue 16069010: extend SkBenchmark to allow a bench to return a durationScale, which allows it to perform fewer act… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: bench/SkBenchmark.h
diff --git a/bench/SkBenchmark.h b/bench/SkBenchmark.h
index 001b3ab679d0a9529b02ea098710ea3d3b7e8b7f..baadb5140a309f9954396c9b0b402ef67d0a2b2f 100644
--- a/bench/SkBenchmark.h
+++ b/bench/SkBenchmark.h
@@ -106,6 +106,20 @@ public:
bool findDefine32(const char* key, int32_t* value) const;
bool findDefineScalar(const char* key, SkScalar* value) const;
+ /**
robertphillips 2013/05/29 13:14:17 // Sets the bit manipulation masks so in ::setupPa
reed1 2013/05/29 15:02:30 Done.
+ * Performs the following on the paint:
+ * uint32_t flags = paint.getFlags();
+ * flags &= ~clearMask;
+ * flags |= orMask;
+ * paint.setFlags(flags);
+ */
+ void setPaintFlags(uint32_t orMask, uint32_t clearMask) {
+ fOrMask = orMask;
+ fClearMask = clearMask;
+ }
+
+ float getDurationScale() { return this->onGetDurationScale(); }
+
protected:
virtual void setupPaint(SkPaint* paint);
@@ -113,6 +127,13 @@ protected:
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.
@@ -126,6 +147,7 @@ private:
SkTriState::State fDither;
bool fHasStrokeWidth;
SkScalar strokeWidth;
+ uint32_t fOrMask, fClearMask;
typedef SkRefCnt INHERITED;
};
« bench/BitmapBench.cpp ('K') | « bench/BitmapBench.cpp ('k') | bench/SkBenchmark.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698