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

Unified Diff: bench/PictureRecordBench.cpp

Issue 18119011: Streamline picture_record_recurring_ bench. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/PictureRecordBench.cpp
diff --git a/bench/PictureRecordBench.cpp b/bench/PictureRecordBench.cpp
index 50020f380fcb9f13a90345877c24cc3c76d6d0c0..f23f0cb961187dabd406e7f83abf036a124d874d 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;
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698