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

Unified Diff: bench/FontCacheBench.cpp

Issue 16374009: add bench for fontcache performance (measurement) (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 | bench/gUniqueGlyphIDs.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/FontCacheBench.cpp
diff --git a/bench/FontCacheBench.cpp b/bench/FontCacheBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4224e87093a93bedb096f1fab2d2635fff5bd914
--- /dev/null
+++ b/bench/FontCacheBench.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkBenchmark.h"
+#include "SkCanvas.h"
+#include "SkFontHost.h"
+#include "SkPaint.h"
+#include "SkString.h"
+#include "SkTemplates.h"
+
+#include "glyphs.h"
+
+class FontCacheBench : public SkBenchmark {
+ enum { N = SkBENCHLOOP(800) };
+public:
+ FontCacheBench(void* param) : INHERITED(param) {
+ }
+
+protected:
+ virtual const char* onGetName() SK_OVERRIDE {
+ return "fontcache";
+ }
+
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ SkPaint paint;
+ this->setupPaint(&paint);
+ paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
+
+ for (int i = 0; i < N; ++i) {
+ const int16_t* array = gUniqueGlyphIDs;
+ while (*array >= 0) {
+ const int16_t* end = array + 1;
+ while (*end >= 0) {
+ end += 1;
+ }
+ paint.measureText(array, end - array);
+ array = end + 1; // skip the sentinel
+ }
+ }
+ }
+
+private:
+ typedef SkBenchmark INHERITED;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
+DEF_BENCH( return new FontCacheBench(p); )
« no previous file with comments | « no previous file | bench/gUniqueGlyphIDs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698