OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "Resources.h" | 9 #include "Resources.h" |
10 #include "SkAutoPixmapStorage.h" | 10 #include "SkAutoPixmapStorage.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 } | 201 } |
202 void onDraw(int loops, SkCanvas*) override { | 202 void onDraw(int loops, SkCanvas*) override { |
203 while (loops-- > 0) { | 203 while (loops-- > 0) { |
204 for (int i = 1000; i-- > 0;) { | 204 for (int i = 1000; i-- > 0;) { |
205 fWStream->writeText("HELLO SKIA!\n"); | 205 fWStream->writeText("HELLO SKIA!\n"); |
206 } | 206 } |
207 } | 207 } |
208 } | 208 } |
209 }; | 209 }; |
210 | 210 |
211 struct WritePDFTextBenchmark : public Benchmark { | |
212 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.
| |
213 WritePDFTextBenchmark() : fWStream(new NullWStream) {} | |
214 const char* onGetName() override { return "WritePDFText"; } | |
215 bool isSuitableFor(Backend backend) override { | |
216 return backend == kNonRendering_Backend; | |
217 } | |
218 void onDraw(int loops, SkCanvas*) override { | |
219 static const char kHello[] = "HELLO SKIA!\n"; | |
220 static const char kBinary[] = "\001\002\003\004\005\006"; | |
221 while (loops-- > 0) { | |
222 for (int i = 1000; i-- > 0;) { | |
223 SkPDFUtils::WriteString(fWStream.get(), kHello, strlen(kHello)); | |
224 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
| |
225 } | |
226 } | |
227 } | |
228 }; | |
229 | |
211 } // namespace | 230 } // namespace |
212 DEF_BENCH(return new PDFImageBench;) | 231 DEF_BENCH(return new PDFImageBench;) |
213 DEF_BENCH(return new PDFJpegImageBench;) | 232 DEF_BENCH(return new PDFJpegImageBench;) |
214 DEF_BENCH(return new PDFCompressionBench;) | 233 DEF_BENCH(return new PDFCompressionBench;) |
215 DEF_BENCH(return new PDFScalarBench;) | 234 DEF_BENCH(return new PDFScalarBench;) |
216 DEF_BENCH(return new PDFShaderBench;) | 235 DEF_BENCH(return new PDFShaderBench;) |
217 DEF_BENCH(return new WStreamWriteTextBenchmark;) | 236 DEF_BENCH(return new WStreamWriteTextBenchmark;) |
237 DEF_BENCH(return new WritePDFTextBenchmark;) | |
OLD | NEW |