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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/Character.cpp ('k') | 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 (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 341
342 EXPECT_TRUE(Character::isCJKIdeographOrSymbol(0x1F100)); 342 EXPECT_TRUE(Character::isCJKIdeographOrSymbol(0x1F100));
343 343
344 TestSpecificUChar32RangeIdeographSymbol(0x1F110, 0x1F129); 344 TestSpecificUChar32RangeIdeographSymbol(0x1F110, 0x1F129);
345 TestSpecificUChar32RangeIdeographSymbol(0x1F130, 0x1F149); 345 TestSpecificUChar32RangeIdeographSymbol(0x1F130, 0x1F149);
346 TestSpecificUChar32RangeIdeographSymbol(0x1F150, 0x1F169); 346 TestSpecificUChar32RangeIdeographSymbol(0x1F150, 0x1F169);
347 TestSpecificUChar32RangeIdeographSymbol(0x1F170, 0x1F189); 347 TestSpecificUChar32RangeIdeographSymbol(0x1F170, 0x1F189);
348 TestSpecificUChar32RangeIdeographSymbol(0x1F200, 0x1F6FF); 348 TestSpecificUChar32RangeIdeographSymbol(0x1F200, 0x1F6FF);
349 } 349 }
350 350
351 void measureUScript(UChar32 min, UChar32 max, UScriptCode* scripts)
352 {
353 for (UChar32 ch = min; ch <= max; ch++) {
354 UErrorCode status = U_ZERO_ERROR;
355 UScriptCode script = uscript_getScript(ch, &status);
356 if (U_FAILURE(status)) {
357 if (scripts)
358 *scripts++ = USCRIPT_INVALID_CODE;
359 continue;
360 }
361 if (scripts)
362 *scripts++ = script;
363 }
364 }
365
366 void measureIsCJKIdeographOrSymbol(UChar32 min, UChar32 max, bool* results)
367 {
368 for (UChar32 ch = min; ch <= max; ch++) {
369 bool result = Character::isCJKIdeographOrSymbol(ch);
370 if (results)
371 *results++ = result;
372 }
373 }
374
375 #define P(name, min, max, iteration) \
376 TEST(FontTest, Perf ## name ## UScript) \
377 { \
378 for (int i = 0; i < iteration; i++) \
379 measureUScript(min, max, nullptr); \
380 } \
381 TEST(FontTest, Perf ## name ## IsCJKIdeographOrSymbol) \
382 { \
383 for (int i = 0; i < iteration; i++) \
384 measureIsCJKIdeographOrSymbol(min, max, nullptr); \
385 }
386 P(All, 0x0000, 0x1FFFFF, 10)
387 P(ASCII, 0x0020, 0x007E, 100000)
388 P(Han, 0x4E00, 0x9FFF, 1000)
389 P(Hira, 0x3041, 0x3093, 10000)
390 P(Arabic, 0x0600, 0x06FF, 10000)
391
351 } // namespace blink 392 } // namespace blink
352
OLDNEW
« 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