diff options
author | 2011-01-05 14:13:07 +0900 | |
---|---|---|
committer | 2011-01-05 15:47:29 +0900 | |
commit | 61e2f85e3fe6c0cc266996bc9a3692ed5795fad3 (patch) | |
tree | a7ec7bb9e1ad7e0380b29a1ddb2d188c862761f5 /native/src/unigram_dictionary.cpp | |
parent | 458249e703bded3a1cbd25a2ab2249f9366a8188 (diff) | |
download | latinime-61e2f85e3fe6c0cc266996bc9a3692ed5795fad3.tar.gz latinime-61e2f85e3fe6c0cc266996bc9a3692ed5795fad3.tar.xz latinime-61e2f85e3fe6c0cc266996bc9a3692ed5795fad3.zip |
Add profiler for native dictionary code
Change-Id: I2569756c9ef4fa677ae52f2ccfcb90d2115d129f
Diffstat (limited to 'native/src/unigram_dictionary.cpp')
-rw-r--r-- | native/src/unigram_dictionary.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/native/src/unigram_dictionary.cpp b/native/src/unigram_dictionary.cpp index f679001cf..5e1212a5d 100644 --- a/native/src/unigram_dictionary.cpp +++ b/native/src/unigram_dictionary.cpp @@ -42,14 +42,20 @@ UnigramDictionary::UnigramDictionary(const unsigned char *dict, int typedLetterM UnigramDictionary::~UnigramDictionary() {} int UnigramDictionary::getSuggestions(int *codes, int codesSize, unsigned short *outWords, - int *frequencies, int *nextLetters, int nextLettersSize) -{ + int *frequencies, int *nextLetters, int nextLettersSize) { + PROF_OPEN; + PROF_START(0); initSuggestions(codes, codesSize, outWords, frequencies); if (DEBUG_DICT) assert(codesSize == mInputLength); const int MAX_DEPTH = min(mInputLength * MAX_DEPTH_MULTIPLIER, MAX_WORD_LENGTH); + PROF_END(0); + + PROF_START(1); getSuggestionCandidates(-1, -1, -1, nextLetters, nextLettersSize, MAX_DEPTH); + PROF_END(1); + PROF_START(2); // Suggestion with missing character if (SUGGEST_WORDS_WITH_MISSING_CHARACTER) { for (int i = 0; i < codesSize; ++i) { @@ -57,7 +63,9 @@ int UnigramDictionary::getSuggestions(int *codes, int codesSize, unsigned short getSuggestionCandidates(i, -1, -1, NULL, 0, MAX_DEPTH); } } + PROF_END(2); + PROF_START(3); // Suggestion with excessive character if (SUGGEST_WORDS_WITH_EXCESSIVE_CHARACTER && mInputLength >= MIN_USER_TYPED_LENGTH_FOR_EXCESSIVE_CHARACTER_SUGGESTION) { @@ -66,7 +74,9 @@ int UnigramDictionary::getSuggestions(int *codes, int codesSize, unsigned short getSuggestionCandidates(-1, i, -1, NULL, 0, MAX_DEPTH); } } + PROF_END(3); + PROF_START(4); // Suggestion with transposed characters // Only suggest words that length is mInputLength if (SUGGEST_WORDS_WITH_TRANSPOSED_CHARACTERS) { @@ -75,7 +85,9 @@ int UnigramDictionary::getSuggestions(int *codes, int codesSize, unsigned short getSuggestionCandidates(-1, -1, i, NULL, 0, mInputLength - 1); } } + PROF_END(4); + PROF_START(5); // Suggestions with missing space if (SUGGEST_WORDS_WITH_MISSING_SPACE_CHARACTER && mInputLength >= MIN_USER_TYPED_LENGTH_FOR_MISSING_SPACE_SUGGESTION) { @@ -84,7 +96,9 @@ int UnigramDictionary::getSuggestions(int *codes, int codesSize, unsigned short getMissingSpaceWords(mInputLength, i); } } + PROF_END(5); + PROF_START(6); // Get the word count int suggestedWordsCount = 0; while (suggestedWordsCount < MAX_WORDS && mFrequencies[suggestedWordsCount] > 0) { @@ -101,7 +115,8 @@ int UnigramDictionary::getSuggestions(int *codes, int codesSize, unsigned short } LOGI("\n"); } - + PROF_END(6); + PROF_CLOSE; return suggestedWordsCount; } |