aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-11 14:26:09 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-11 14:26:09 +0000
commit0c4e21da9598a2eb5324e90ac8648048a1a34636 (patch)
tree836e3a7e1c63de71ec0618e86eece09d959e5cfd /bench
parentab4098b4d3ceb952dc7bea7e28a38387830acad6 (diff)
Streamline picture_record_recurring_ bench.
Reduce benchmark runtime from ~17 ms to ~13.25ms by moving SkPaint construction out of the inner loop and by using random colors in the SkPaints instead of sequential integers, which were seeing bad hashing. This doesn't actually improve our performance, but makes the benchmark more focused on pure recording costs. BUG= R=mtklein@google.com, reed@google.com, tomhudson@google.com Author: tomhudson@chromium.org Review URL: https://chromiumcodereview.appspot.com/18119011 git-svn-id: http://skia.googlecode.com/svn/trunk@10003 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench')
-rw-r--r--bench/PictureRecordBench.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/bench/PictureRecordBench.cpp b/bench/PictureRecordBench.cpp
index 50020f380f..f23f0cb961 100644
--- a/bench/PictureRecordBench.cpp
+++ b/bench/PictureRecordBench.cpp
@@ -157,12 +157,21 @@ private:
/*
* Populates the SkPaint dictionary with a number of unique paint
- * objects that get reused repeatedly
+ * objects that get reused repeatedly.
+ *
+ * Re-creating the paint objects in the inner loop slows the benchmark down 10%.
+ * Using setColor(i % objCount) instead of a random color creates a very high rate
+ * of hash conflicts, slowing us down 12%.
*/
class RecurringPaintDictionaryRecordBench : public PictureRecordBench {
public:
RecurringPaintDictionaryRecordBench(void* param)
- : INHERITED(param, "recurring_paint_dictionary") { }
+ : INHERITED(param, "recurring_paint_dictionary") {
+ SkRandom rand;
+ for (int i = 0; i < ObjCount; i++) {
+ fPaint[i].setColor(rand.nextU());
+ }
+ }
enum {
ObjCount = 100, // number of unique paint objects
@@ -173,13 +182,12 @@ protected:
virtual void recordCanvas(SkCanvas* canvas) {
for (int i = 0; i < M; i++) {
- SkPaint paint;
- paint.setColor(i % ObjCount);
- canvas->drawPaint(paint);
+ canvas->drawPaint(fPaint[i % ObjCount]);
}
}
private:
+ SkPaint fPaint [ObjCount];
typedef PictureRecordBench INHERITED;
};