Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add perf stat for applying styles in binary resources #6869

Merged
merged 1 commit into from Nov 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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