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

Unified Diff: bench/PictureOverheadBench.cpp

Issue 1063723002: Expand bench to cover no-draw SkPictures too. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 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/PictureOverheadBench.cpp
diff --git a/bench/PictureOverheadBench.cpp b/bench/PictureOverheadBench.cpp
index 884b005ee7f5f09dd74a5066311ab295655d6e21..c9dedf402bb5335d4116e78dab46b606df0ef847 100644
--- a/bench/PictureOverheadBench.cpp
+++ b/bench/PictureOverheadBench.cpp
@@ -6,24 +6,30 @@
*/
// A benchmark designed to isolate the constant overheads of picture recording.
-// We record a very tiny (one op) picture; one op is better than none, as it forces
-// us to allocate memory to store that op... we can't just cheat by holding onto NULLs.
+// We record an empty picture and a picture with one draw op to force memory allocation.
#include "Benchmark.h"
#include "SkCanvas.h"
#include "SkPictureRecorder.h"
+template <bool kDraw>
struct PictureOverheadBench : public Benchmark {
- const char* onGetName() override { return "picture_overhead"; }
+ const char* onGetName() override {
+ return kDraw ? "picture_overhead_draw" : "picture_overhead_nodraw";
+ }
bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
void onDraw(const int loops, SkCanvas*) override {
SkPictureRecorder rec;
for (int i = 0; i < loops; i++) {
- SkCanvas* c = rec.beginRecording(SkRect::MakeWH(2000,3000));
- c->drawRect(SkRect::MakeXYWH(10, 10, 1000, 1000), SkPaint());
+ rec.beginRecording(SkRect::MakeWH(2000,3000));
+ if (kDraw) {
+ rec.getRecordingCanvas()->drawRect(SkRect::MakeXYWH(10, 10, 1000, 1000), SkPaint());
+ }
SkAutoTUnref<SkPicture> pic(rec.endRecordingAsPicture());
}
}
};
-DEF_BENCH(return new PictureOverheadBench;)
+
+DEF_BENCH(return (new PictureOverheadBench<false>);)
+DEF_BENCH(return (new PictureOverheadBench< true>);)
« 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