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

Unified Diff: tools/bench_record.cpp

Issue 136873002: Add no-op NULL picture to bench_record. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 11 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: tools/bench_record.cpp
diff --git a/tools/bench_record.cpp b/tools/bench_record.cpp
index 219a6b9383cc1290a037a84b6577251cdf8815c8..cea3f0b6267ac34fcb4cfab0c55559bae11e0bcb 100644
--- a/tools/bench_record.cpp
+++ b/tools/bench_record.cpp
@@ -24,41 +24,54 @@ DEFINE_string2(skps, r, "skps", "Directory containing SKPs to read and re-record
DEFINE_int32(loops, 900, "Number of times to re-record each SKP.");
DEFINE_int32(flags, SkPicture::kUsePathBoundsForClip_RecordingFlag, "RecordingFlags to use.");
DEFINE_bool(endRecording, true, "If false, don't time SkPicture::endRecording()");
+DEFINE_int32(nullSize, 1000, "Pretend dimension of null source picture.");
+
+static void bench_record(SkPicture* src, const char* name) {
+ const SkMSec start = SkTime::GetMSecs();
+ const int width = src ? src->width() : FLAGS_nullSize;
+ const int height = src ? src->height() : FLAGS_nullSize;
+
+ for (int i = 0; i < FLAGS_loops; i++) {
+ SkPicture dst;
+ SkCanvas* canvas = dst.beginRecording(width, height, FLAGS_flags);
+ if (src) src->draw(canvas);
+ if (FLAGS_endRecording) dst.endRecording();
+ }
+
+ const SkMSec elapsed = SkTime::GetMSecs() - start;
+ const double msPerLoop = elapsed / (double)FLAGS_loops;
+ printf("%.2g\t%s\n", msPerLoop, name);
+}
int tool_main(int argc, char** argv);
int tool_main(int argc, char** argv) {
SkCommandLineFlags::Parse(argc, argv);
SkAutoGraphics autoGraphics;
+ bench_record(NULL, "NULL");
+ if (FLAGS_skps.isEmpty()) return 0;
+
SkOSFile::Iter it(FLAGS_skps[0], ".skp");
SkString filename;
+ bool failed = false;
while (it.next(&filename)) {
const SkString path = SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str());
SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path.c_str()));
if (!stream) {
SkDebugf("Could not read %s.\n", path.c_str());
+ failed = true;
continue;
}
SkAutoTUnref<SkPicture> src(SkPicture::CreateFromStream(stream));
if (!src) {
SkDebugf("Could not read %s as an SkPicture.\n", path.c_str());
+ failed = true;
continue;
}
-
- const SkMSec start = SkTime::GetMSecs();
- for (int i = 0; i < FLAGS_loops; i++) {
- SkPicture dst;
- src->draw(dst.beginRecording(src->width(), src->height(), FLAGS_flags));
- if (FLAGS_endRecording) dst.endRecording();
- }
-
- const SkMSec elapsed = SkTime::GetMSecs() - start;
- const double msPerLoop = elapsed / (double)FLAGS_loops;
- printf("%4.2f\t%s\n", msPerLoop, filename.c_str());
+ bench_record(src, filename.c_str());
}
-
- return 0;
+ return failed ? 1 : 0;
}
#if !defined SK_BUILD_FOR_IOS
« 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