Skip to content

Commit

Permalink
Merge pull request #6869 from robolectric/piper_410883839
Browse files Browse the repository at this point in the history
Add perf stat for applying styles in binary resources
  • Loading branch information
hoisie committed Nov 20, 2021
2 parents c4586ca + 1516fa1 commit 190679d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
Expand Up @@ -73,6 +73,7 @@
import org.robolectric.res.android.ResXMLTree;
import org.robolectric.res.android.ResourceTypes.Res_value;
import org.robolectric.shadow.api.Shadow;
import org.robolectric.util.PerfStatsCollector;
import org.robolectric.util.ReflectionHelpers;
import org.robolectric.util.ReflectionHelpers.ClassParameter;
import org.robolectric.util.reflector.Direct;
Expand Down Expand Up @@ -1388,6 +1389,30 @@ protected static void nativeApplyStyle(
@NonNull int[] java_attrs,
long out_values_ptr,
long out_indices_ptr) {
PerfStatsCollector.getInstance()
.measure(
"applyStyle",
() ->
nativeApplyStyle_measured(
ptr,
theme_ptr,
def_style_attr,
def_style_resid,
xml_parser_ptr,
java_attrs,
out_values_ptr,
out_indices_ptr));
}

private static void nativeApplyStyle_measured(
long ptr,
long theme_ptr,
@AttrRes int def_style_attr,
@StyleRes int def_style_resid,
long xml_parser_ptr,
@NonNull int[] java_attrs,
long out_values_ptr,
long out_indices_ptr) {
CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
Theme theme = Registries.NATIVE_THEME9_REGISTRY.getNativeObject(theme_ptr);
CHECK(theme.GetAssetManager() == assetmanager);
Expand Down
Expand Up @@ -73,6 +73,7 @@
import org.robolectric.res.android.ResXMLTree;
import org.robolectric.res.android.ResourceTypes.Res_value;
import org.robolectric.shadow.api.Shadow;
import org.robolectric.util.PerfStatsCollector;
import org.robolectric.util.ReflectionHelpers;
import org.robolectric.util.ReflectionHelpers.ClassParameter;
import org.robolectric.util.reflector.Direct;
Expand Down Expand Up @@ -1378,6 +1379,30 @@ protected static void nativeApplyStyle(
@NonNull int[] java_attrs,
long out_values_ptr,
long out_indices_ptr) {
PerfStatsCollector.getInstance()
.measure(
"applyStyle",
() ->
nativeApplyStyle_measured(
ptr,
theme_ptr,
def_style_attr,
def_style_resid,
xml_parser_ptr,
java_attrs,
out_values_ptr,
out_indices_ptr));
}

private static void nativeApplyStyle_measured(
long ptr,
long theme_ptr,
@AttrRes int def_style_attr,
@StyleRes int def_style_resid,
long xml_parser_ptr,
@NonNull int[] java_attrs,
long out_values_ptr,
long out_indices_ptr) {
CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
Theme theme = Registries.NATIVE_THEME9_REGISTRY.getNativeObject(theme_ptr);
CHECK(theme.GetAssetManager() == assetmanager);
Expand Down

0 comments on commit 190679d

Please sign in to comment.