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

Unified Diff: third_party/WebKit/Source/platform/fonts/FontTest.cpp

Issue 1541393003: Improve performance of Character::isCJKIdeographOrSymbol by using trie tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Linux/Mac compile error Created 4 years, 11 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 | « third_party/WebKit/Source/platform/fonts/Character.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/fonts/FontTest.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/FontTest.cpp b/third_party/WebKit/Source/platform/fonts/FontTest.cpp
index c38c10dba6bf2e3c0622969c92a96726d389231d..26a0ff572b1178cbc55cdc4a0c9e39d548e68d1e 100644
--- a/third_party/WebKit/Source/platform/fonts/FontTest.cpp
+++ b/third_party/WebKit/Source/platform/fonts/FontTest.cpp
@@ -348,5 +348,45 @@ TEST(FontTest, TestIsCJKIdeographOrSymbol)
TestSpecificUChar32RangeIdeographSymbol(0x1F200, 0x1F6FF);
}
-} // namespace blink
+void measureUScript(UChar32 min, UChar32 max, UScriptCode* scripts)
+{
+ for (UChar32 ch = min; ch <= max; ch++) {
+ UErrorCode status = U_ZERO_ERROR;
+ UScriptCode script = uscript_getScript(ch, &status);
+ if (U_FAILURE(status)) {
+ if (scripts)
+ *scripts++ = USCRIPT_INVALID_CODE;
+ continue;
+ }
+ if (scripts)
+ *scripts++ = script;
+ }
+}
+void measureIsCJKIdeographOrSymbol(UChar32 min, UChar32 max, bool* results)
+{
+ for (UChar32 ch = min; ch <= max; ch++) {
+ bool result = Character::isCJKIdeographOrSymbol(ch);
+ if (results)
+ *results++ = result;
+ }
+}
+
+#define P(name, min, max, iteration) \
+TEST(FontTest, Perf ## name ## UScript) \
+{ \
+ for (int i = 0; i < iteration; i++) \
+ measureUScript(min, max, nullptr); \
+} \
+TEST(FontTest, Perf ## name ## IsCJKIdeographOrSymbol) \
+{ \
+ for (int i = 0; i < iteration; i++) \
+ measureIsCJKIdeographOrSymbol(min, max, nullptr); \
+}
+P(All, 0x0000, 0x1FFFFF, 10)
+P(ASCII, 0x0020, 0x007E, 100000)
+P(Han, 0x4E00, 0x9FFF, 1000)
+P(Hira, 0x3041, 0x3093, 10000)
+P(Arabic, 0x0600, 0x06FF, 10000)
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/Character.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698