OLD | NEW |
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 Loading... |
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 | |
OLD | NEW |