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

Side by Side Diff: bench/PDFBench.cpp

Issue 1735063004: SkPDF/Bench becnchmark new SkPDFUtils::FloatToDecimal function. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-03-09 (Wednesday) 13:28:39 EST Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkData.h" 10 #include "SkData.h"
11 #include "SkImage.h" 11 #include "SkImage.h"
12 #include "SkPDFBitmap.h" 12 #include "SkPDFBitmap.h"
13 #include "SkPDFUtils.h"
13 #include "SkPixmap.h" 14 #include "SkPixmap.h"
15 #include "SkRandom.h"
14 16
15 namespace { 17 namespace {
16 struct NullWStream : public SkWStream { 18 struct NullWStream : public SkWStream {
17 NullWStream() : fN(0) {} 19 NullWStream() : fN(0) {}
18 bool write(const void*, size_t n) override { fN += n; return true; } 20 bool write(const void*, size_t n) override { fN += n; return true; }
19 size_t bytesWritten() const override { return fN; } 21 size_t bytesWritten() const override { return fN; }
20 size_t fN; 22 size_t fN;
21 }; 23 };
22 24
23 static void test_pdf_object_serialization(SkPDFObject* object) { 25 static void test_pdf_object_serialization(SkPDFObject* object) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 SkAutoTUnref<SkPDFObject> object( 140 SkAutoTUnref<SkPDFObject> object(
139 new SkPDFSharedStream(fAsset->duplicate())); 141 new SkPDFSharedStream(fAsset->duplicate()));
140 test_pdf_object_serialization(object); 142 test_pdf_object_serialization(object);
141 } 143 }
142 } 144 }
143 145
144 private: 146 private:
145 SkAutoTDelete<SkStreamAsset> fAsset; 147 SkAutoTDelete<SkStreamAsset> fAsset;
146 }; 148 };
147 149
150 // Test speed of SkPDFUtils::FloatToDecimal for typical floats that
151 // might be found in a PDF document.
152 struct PDFScalarBench : public Benchmark {
153 bool isSuitableFor(Backend b) override {
154 return b == kNonRendering_Backend;
155 }
156 const char* onGetName() override { return "PDFScalar"; }
157 void onDraw(int loops, SkCanvas*) override {
158 SkRandom random;
159 char dst[SkPDFUtils::kMaximumFloatDecimalLength];
160 while (loops-- > 0) {
161 auto f = random.nextRangeF(-500.0f, 1500.0f);
162 (void)SkPDFUtils::FloatToDecimal(f, dst);
163 }
164 }
165 };
166
148 } // namespace 167 } // namespace
149 DEF_BENCH(return new PDFImageBench;) 168 DEF_BENCH(return new PDFImageBench;)
150 DEF_BENCH(return new PDFJpegImageBench;) 169 DEF_BENCH(return new PDFJpegImageBench;)
151 DEF_BENCH(return new PDFCompressionBench;) 170 DEF_BENCH(return new PDFCompressionBench;)
171 DEF_BENCH(return new PDFScalarBench;)
OLDNEW
« 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