Cache resolved theme values
When calling Resources#obtainStyledAttributes, if a value for an
attribute is supplied from the theme, and the value in the theme
is a reference to a resource, the reference will be resolved using
AssetManager2::ResolveReference each time the value from the theme
is selected. This causes Resources#obtainStyledAttributes to do
repeated work every time the same attribute is supplied from the
theme in multiple invocations.
Caching the result of ResolveReference reduces the cost of this
repeated work and reduces the amount of time needed to inflate views.
Before:
com.android.resources.perf (3 Tests)
[1/3] com.android.resources.perf.PerfTest#youtube: PASSED (11.748s)
youtube_ns_median: 95490747
youtube_ns_standardDeviation: 7282249
youtube_ns_mean: 98442515
[2/3] com.android.resources.perf.PerfTest#maps: PASSED (10.862s)
maps_ns_standardDeviation: 4484213
maps_ns_mean: 87912988
maps_ns_median: 86325549
[3/3] com.android.resources.perf.PerfTest#gmail: PASSED (24.034s)
gmail_ns_median: 282175838
gmail_ns_standardDeviation: 6560876
gmail_ns_mean: 282869146
After:
com.android.resources.perf (3 Tests)
[1/3] com.android.resources.perf.PerfTest#youtube: PASSED (11.245s)
youtube_ns_median: 92292347
youtube_ns_standardDeviation: 5899906
youtube_ns_mean: 93045239
[2/3] com.android.resources.perf.PerfTest#maps: PASSED (10.583s)
maps_ns_standardDeviation: 7567929
maps_ns_mean: 81895979
maps_ns_median: 78647883
[3/3] com.android.resources.perf.PerfTest#gmail: PASSED (21.439s)
gmail_ns_median: 229185043
gmail_ns_standardDeviation: 8770133
gmail_ns_mean: 232561234
These tests were done on a Pixel 3 and with cpu settings configured by
libs/hwui/tests/scripts/prep_generic.sh:
Locked CPUs 4,5,6,7 to 1459200 / 2803200 KHz
Disabled CPUs 0,1,2,3
Bug: 170232288
Test: atest ResourcesPerfWorkloads
Change-Id: I1e9e9acaa40fa60475a0e55230e11243f5b69b39
3 files changed