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

Unified 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 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: bench/PDFBench.cpp
diff --git a/bench/PDFBench.cpp b/bench/PDFBench.cpp
index 5f839f05d01bbf2002d04b7b5a1805adb64896fc..b7f48daac8a2dfa4b8ed115dd92b432504bda04b 100644
--- a/bench/PDFBench.cpp
+++ b/bench/PDFBench.cpp
@@ -10,7 +10,9 @@
#include "SkData.h"
#include "SkImage.h"
#include "SkPDFBitmap.h"
+#include "SkPDFUtils.h"
#include "SkPixmap.h"
+#include "SkRandom.h"
namespace {
struct NullWStream : public SkWStream {
@@ -145,7 +147,25 @@ private:
SkAutoTDelete<SkStreamAsset> fAsset;
};
+// Test speed of SkPDFUtils::FloatToDecimal for typical floats that
+// might be found in a PDF document.
+struct PDFScalarBench : public Benchmark {
+ bool isSuitableFor(Backend b) override {
+ return b == kNonRendering_Backend;
+ }
+ const char* onGetName() override { return "PDFScalar"; }
+ void onDraw(int loops, SkCanvas*) override {
+ SkRandom random;
+ char dst[SkPDFUtils::kMaximumFloatDecimalLength];
+ while (loops-- > 0) {
+ auto f = random.nextRangeF(-500.0f, 1500.0f);
+ (void)SkPDFUtils::FloatToDecimal(f, dst);
+ }
+ }
+};
+
} // namespace
DEF_BENCH(return new PDFImageBench;)
DEF_BENCH(return new PDFJpegImageBench;)
DEF_BENCH(return new PDFCompressionBench;)
+DEF_BENCH(return new PDFScalarBench;)
« 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