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
diff --git a/bench/PictureRecordBench.cpp b/bench/PictureRecordBench.cpp
index 50020f3..f23f0cb 100644
--- a/bench/PictureRecordBench.cpp
+++ b/bench/PictureRecordBench.cpp
@@ -157,12 +157,21 @@
 
 /*
  *  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 @@
     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;
 };