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

Side by Side Diff: bench/PDFBench.cpp

Issue 2151863003: SkPdf: smaller color serialization (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: SkFixed - 2016-07-15 (Friday) 15:45:32 EDT Created 4 years, 5 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 | src/pdf/SkPDFDevice.cpp » ('j') | 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 "SkAutoPixmapStorage.h" 10 #include "SkAutoPixmapStorage.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 void onDraw(int loops, SkCanvas*) override { 157 void onDraw(int loops, SkCanvas*) override {
158 SkRandom random; 158 SkRandom random;
159 char dst[SkPDFUtils::kMaximumFloatDecimalLength]; 159 char dst[SkPDFUtils::kMaximumFloatDecimalLength];
160 while (loops-- > 0) { 160 while (loops-- > 0) {
161 auto f = random.nextRangeF(-500.0f, 1500.0f); 161 auto f = random.nextRangeF(-500.0f, 1500.0f);
162 (void)SkPDFUtils::FloatToDecimal(f, dst); 162 (void)SkPDFUtils::FloatToDecimal(f, dst);
163 } 163 }
164 } 164 }
165 }; 165 };
166 166
167 struct PDFColorComponentBench : public Benchmark {
168 bool isSuitableFor(Backend b) override {
169 return b == kNonRendering_Backend;
170 }
171 const char* onGetName() override { return "PDFColorComponent"; }
172 void onDraw(int loops, SkCanvas*) override {
173 char dst[5];
174 while (loops-- > 0) {
175 for (int i = 0; i < 256; ++i) {
176 (void)SkPDFUtils::ColorToDecimal(SkToU8(i), dst);
177 }
178 }
179 }
180 };
181
167 struct PDFShaderBench : public Benchmark { 182 struct PDFShaderBench : public Benchmark {
168 sk_sp<SkShader> fShader; 183 sk_sp<SkShader> fShader;
169 const char* onGetName() final { return "PDFShader"; } 184 const char* onGetName() final { return "PDFShader"; }
170 bool isSuitableFor(Backend b) final { return b == kNonRendering_Backend; } 185 bool isSuitableFor(Backend b) final { return b == kNonRendering_Backend; }
171 void onDelayedSetup() final { 186 void onDelayedSetup() final {
172 const SkPoint pts[2] = {{0.0f, 0.0f}, {100.0f, 100.0f}}; 187 const SkPoint pts[2] = {{0.0f, 0.0f}, {100.0f, 100.0f}};
173 const SkColor colors[] = { 188 const SkColor colors[] = {
174 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, 189 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE,
175 SK_ColorWHITE, SK_ColorBLACK, 190 SK_ColorWHITE, SK_ColorBLACK,
176 }; 191 };
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 240 }
226 } 241 }
227 } 242 }
228 }; 243 };
229 244
230 } // namespace 245 } // namespace
231 DEF_BENCH(return new PDFImageBench;) 246 DEF_BENCH(return new PDFImageBench;)
232 DEF_BENCH(return new PDFJpegImageBench;) 247 DEF_BENCH(return new PDFJpegImageBench;)
233 DEF_BENCH(return new PDFCompressionBench;) 248 DEF_BENCH(return new PDFCompressionBench;)
234 DEF_BENCH(return new PDFScalarBench;) 249 DEF_BENCH(return new PDFScalarBench;)
250 DEF_BENCH(return new PDFColorComponentBench;)
235 DEF_BENCH(return new PDFShaderBench;) 251 DEF_BENCH(return new PDFShaderBench;)
236 DEF_BENCH(return new WStreamWriteTextBenchmark;) 252 DEF_BENCH(return new WStreamWriteTextBenchmark;)
237 DEF_BENCH(return new WritePDFTextBenchmark;) 253 DEF_BENCH(return new WritePDFTextBenchmark;)
OLDNEW
« no previous file with comments | « no previous file | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698