Introduce PremeasuredText
By measuring the character widths beforehand, we can save at least 40% of the StaticLayout construction time which typically happens on UI thread. Also verified this doesn't cause performance regression for not premeasured text. Raw performance score (Not premeasured -> premeasured, median, N=100) No Style, Greedy, Hyphenation OFF: 7,812,975 -> 503,245 (-93.6%) No Style, Balanced, Hyphenation OFF: 7,843,254 -> 396,892 (-95.0%) No Style, Greedy, Hyphenation ON : 19,134,214 -> 11,658,928 (-39.1%) No Style, Balanced, Hyphenation ON : 19,348,062 -> 11,634,942 (-39.9%) Styled, Greedy, Hyphenation OFF: 14,353,673 -> 572,840 (-96.0%) Raw performance score (w/o patch -> w/ patch, median, N=100): No Style, Greedy, Hyphenation OFF: 7,732,894 -> 7,812,975 (+1.04%) No Style, Balanced, Hyphenation OFF: 7,884,510 -> 7,843,254 (-0.52%) No Style, Greedy, Hyphenation ON : 18,986,958 -> 19,134,214 (+0.78%) No Style, Balanced, Hyphenation ON : 19,232,791 -> 19,348,062 (+0.60%) Styled, Greedy, Hyphenation OFF: 14,319,690 -> 14,353,673 (+0.24%) Bug: 67504091 Test: bit CtsTextTestCases:* Test: bit CtsGraphicsTestCases:* Test: bit CtsWidgetTestCases:* Test: FrameworksCoreTests:android.text.MeasuredTextTest Change-Id: I0b46f04b42cc012606a9c722eca0d51147a0dcc7
Loading
Please register or sign in to comment