Avoid calling ULocale.to/forLanguageTag for performance reason
Two improvements:
1. Avoid calling ULocale.to/forLanguageTag
2. Improve performance of generateLanguageBundles by not processing
languages with low score. (Almost every languages were in the result
list, and most of them have a super low score).
Benchmark results of classifyText (by running TextClassifierPerfTest):
Old(ns) New(ns) Change(%)
Address 14860227 11327121 -23.78%
size=10 12995548 9718494 -25.22%
size=100 11114050 8194467 -26.27%
size=1000 14670584 11738304 -19.99%
TODO: Checkin the change in TextClassifierPerfTest
This change does not optimize detectLanguage API because
we cannot avoid using ULocale there due to API requirements.
TODO: Consider to cache the ULocale object if it is really necessary.
Test: atest TextClassifierServiceTest
BUG: 140286406
Change-Id: I7433607b4a7b1aa184330cf02f72d37a0f8e3f96
7 files changed