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

Unified Diff: bench/PDFBench.cpp

Issue 2099463002: SkPDF: alloc less memory for strings (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-06-23 (Thursday) 16:23:34 EDT Created 4 years, 6 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 | src/pdf/SkPDFDevice.cpp » ('j') | src/pdf/SkPDFDevice.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/PDFBench.cpp
diff --git a/bench/PDFBench.cpp b/bench/PDFBench.cpp
index 76ee3cad0d57cda8015d82993528c5fecb446812..8f5d2db5b4a51b78f40307e452d583395b761643 100644
--- a/bench/PDFBench.cpp
+++ b/bench/PDFBench.cpp
@@ -208,6 +208,25 @@ struct WStreamWriteTextBenchmark : public Benchmark {
}
};
+struct WritePDFTextBenchmark : public Benchmark {
+ std::unique_ptr<SkWStream> fWStream;
tomhudson 2016/06/23 20:39:11 We prefer std::unique_ptr<> to sk_sp<>, I suppose?
hal.canary 2016/06/23 20:57:12 streams aren't ref-counted.
+ WritePDFTextBenchmark() : fWStream(new NullWStream) {}
+ const char* onGetName() override { return "WritePDFText"; }
+ bool isSuitableFor(Backend backend) override {
+ return backend == kNonRendering_Backend;
+ }
+ void onDraw(int loops, SkCanvas*) override {
+ static const char kHello[] = "HELLO SKIA!\n";
+ static const char kBinary[] = "\001\002\003\004\005\006";
+ while (loops-- > 0) {
+ for (int i = 1000; i-- > 0;) {
+ SkPDFUtils::WriteString(fWStream.get(), kHello, strlen(kHello));
+ SkPDFUtils::WriteString(fWStream.get(), kBinary, strlen(kBinary));
tomhudson 2016/06/23 20:39:11 Are we getting a free invisible string terminator
hal.canary 2016/06/23 20:57:12 yes
+ }
+ }
+ }
+};
+
} // namespace
DEF_BENCH(return new PDFImageBench;)
DEF_BENCH(return new PDFJpegImageBench;)
@@ -215,3 +234,4 @@ DEF_BENCH(return new PDFCompressionBench;)
DEF_BENCH(return new PDFScalarBench;)
DEF_BENCH(return new PDFShaderBench;)
DEF_BENCH(return new WStreamWriteTextBenchmark;)
+DEF_BENCH(return new WritePDFTextBenchmark;)
« no previous file with comments | « no previous file | src/pdf/SkPDFDevice.cpp » ('j') | src/pdf/SkPDFDevice.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698