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

Side by Side Diff: source/test/perf/dicttrieperf/dicttrieperf.cpp

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 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
OLDNEW
1 /* 1 /*
2 ********************************************************************** 2 **********************************************************************
3 * Copyright (C) 2010-2012, International Business Machines 3 * Copyright (C) 2010-2014, International Business Machines
4 * Corporation and others. All Rights Reserved. 4 * Corporation and others. All Rights Reserved.
5 ********************************************************************** 5 **********************************************************************
6 * file name: dicttrieperf.cpp 6 * file name: dicttrieperf.cpp
7 * encoding: US-ASCII 7 * encoding: US-ASCII
8 * tab size: 8 (not used) 8 * tab size: 8 (not used)
9 * indentation:4 9 * indentation:4
10 * 10 *
11 * created on: 2010dec09 11 * created on: 2010dec09
12 * created by: Markus W. Scherer 12 * created by: Markus W. Scherer
13 * 13 *
(...skipping 16 matching lines...) Expand all
30 #include "unicode/ucharstrie.h" 30 #include "unicode/ucharstrie.h"
31 #include "unicode/ucharstriebuilder.h" 31 #include "unicode/ucharstriebuilder.h"
32 #include "unicode/uperf.h" 32 #include "unicode/uperf.h"
33 #include "unicode/utext.h" 33 #include "unicode/utext.h"
34 #include "charstr.h" 34 #include "charstr.h"
35 #include "package.h" 35 #include "package.h"
36 #include "toolutil.h" 36 #include "toolutil.h"
37 #include "ucbuf.h" // struct ULine 37 #include "ucbuf.h" // struct ULine
38 #include "uoptions.h" 38 #include "uoptions.h"
39 #include "uvectr32.h" 39 #include "uvectr32.h"
40 40 #include "cmemory.h" // for UPRV_LENGTHOF
41 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
42 41
43 // Test object. 42 // Test object.
44 class DictionaryTriePerfTest : public UPerfTest { 43 class DictionaryTriePerfTest : public UPerfTest {
45 public: 44 public:
46 DictionaryTriePerfTest(int32_t argc, const char *argv[], UErrorCode &status) 45 DictionaryTriePerfTest(int32_t argc, const char *argv[], UErrorCode &status)
47 : UPerfTest(argc, argv, NULL, 0, "", status), numTextLines(0) { 46 : UPerfTest(argc, argv, NULL, 0, "", status), numTextLines(0) {
48 if(hasFile()) { 47 if(hasFile()) {
49 getLines(status); 48 getLines(status);
50 for(int32_t i=0; i<numLines; ++i) { 49 for(int32_t i=0; i<numLines; ++i) {
51 // Skip comment lines (start with a character below 'A'). 50 // Skip comment lines (start with a character below 'A').
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 const ULine *lines=perf.getCachedLines(); 441 const ULine *lines=perf.getCachedLines();
443 int32_t numLines=perf.getNumLines(); 442 int32_t numLines=perf.getNumLines();
444 for(int32_t i=0; i<numLines; ++i) { 443 for(int32_t i=0; i<numLines; ++i) {
445 // Skip comment lines (start with a character below 'A'). 444 // Skip comment lines (start with a character below 'A').
446 if(lines[i].name[0]<0x41) { 445 if(lines[i].name[0]<0x41) {
447 continue; 446 continue;
448 } 447 }
449 utext_openUChars(&text, lines[i].name, lines[i].len, pErrorCode); 448 utext_openUChars(&text, lines[i].name, lines[i].len, pErrorCode);
450 int32_t count=0; 449 int32_t count=0;
451 ucharsTrieMatches(*trie, &text, lines[i].len, 450 ucharsTrieMatches(*trie, &text, lines[i].len,
452 lengths, count, LENGTHOF(lengths)); 451 lengths, count, UPRV_LENGTHOF(lengths));
453 if(count==0 || lengths[count-1]!=lines[i].len) { 452 if(count==0 || lengths[count-1]!=lines[i].len) {
454 fprintf(stderr, "word %ld (0-based) not found\n", (long)i); 453 fprintf(stderr, "word %ld (0-based) not found\n", (long)i);
455 } 454 }
456 } 455 }
457 } 456 }
458 }; 457 };
459 458
460 class UCharsTrieDictContains : public UCharsTrieDictLookup { 459 class UCharsTrieDictContains : public UCharsTrieDictLookup {
461 public: 460 public:
462 UCharsTrieDictContains(const DictionaryTriePerfTest &perfTest) 461 UCharsTrieDictContains(const DictionaryTriePerfTest &perfTest)
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 const ULine *lines=perf.getCachedLines(); 590 const ULine *lines=perf.getCachedLines();
592 int32_t numLines=perf.getNumLines(); 591 int32_t numLines=perf.getNumLines();
593 for(int32_t i=0; i<numLines; ++i) { 592 for(int32_t i=0; i<numLines; ++i) {
594 // Skip comment lines (start with a character below 'A'). 593 // Skip comment lines (start with a character below 'A').
595 if(lines[i].name[0]<0x41) { 594 if(lines[i].name[0]<0x41) {
596 continue; 595 continue;
597 } 596 }
598 utext_openUChars(&text, lines[i].name, lines[i].len, pErrorCode); 597 utext_openUChars(&text, lines[i].name, lines[i].len, pErrorCode);
599 int32_t count=0; 598 int32_t count=0;
600 bytesTrieMatches(*trie, &text, lines[i].len, 599 bytesTrieMatches(*trie, &text, lines[i].len,
601 lengths, count, LENGTHOF(lengths)); 600 lengths, count, UPRV_LENGTHOF(lengths));
602 if(count==0 || lengths[count-1]!=lines[i].len) { 601 if(count==0 || lengths[count-1]!=lines[i].len) {
603 fprintf(stderr, "word %ld (0-based) not found\n", (long)i); 602 fprintf(stderr, "word %ld (0-based) not found\n", (long)i);
604 } 603 }
605 } 604 }
606 } 605 }
607 }; 606 };
608 607
609 class BytesTrieDictContains : public BytesTrieDictLookup { 608 class BytesTrieDictContains : public BytesTrieDictLookup {
610 public: 609 public:
611 BytesTrieDictContains(const DictionaryTriePerfTest &perfTest) 610 BytesTrieDictContains(const DictionaryTriePerfTest &perfTest)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 fprintf(stderr, "DictionaryTriePerfTest() failed: %s\n", errorCode.error Name()); 709 fprintf(stderr, "DictionaryTriePerfTest() failed: %s\n", errorCode.error Name());
711 test.usage(); 710 test.usage();
712 return errorCode.reset(); 711 return errorCode.reset();
713 } 712 }
714 if(!test.run()) { 713 if(!test.run()) {
715 fprintf(stderr, "FAILED: Tests could not be run, please check the argume nts.\n"); 714 fprintf(stderr, "FAILED: Tests could not be run, please check the argume nts.\n");
716 return -1; 715 return -1;
717 } 716 }
718 return 0; 717 return 0;
719 } 718 }
OLDNEW
« no previous file with comments | « source/test/perf/convperf/convperf.cpp ('k') | source/test/perf/howExpensiveIs/howExpensiveIs.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698