Commit 7a4c8732 authored by Tomasz Wiszkowski's avatar Tomasz Wiszkowski Committed by Commit Bot

Add tracing events to trace Omnibox Suggestions performance.

Bug: 982818
Change-Id: I49058c6b533e0f7355020b3c9bf7644d25bf5e56
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2052597Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarPatrick Noland <pnoland@chromium.org>
Commit-Queue: Ender <ender@google.com>
Cr-Commit-Position: refs/heads/master@{#742316}
parent 388f1d99
...@@ -22,6 +22,7 @@ import android.widget.ListView; ...@@ -22,6 +22,7 @@ import android.widget.ListView;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import org.chromium.base.TraceEvent;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.util.KeyNavigationUtil; import org.chromium.chrome.browser.util.KeyNavigationUtil;
import org.chromium.components.browser_ui.styles.ChromeColors; import org.chromium.components.browser_ui.styles.ChromeColors;
...@@ -144,28 +145,30 @@ public class OmniboxSuggestionsList extends ListView { ...@@ -144,28 +145,30 @@ public class OmniboxSuggestionsList extends ListView {
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final long start = Debug.threadCpuTimeNanos(); try (TraceEvent tracing = TraceEvent.scoped("OmniboxSuggestionsList.Measure")) {
View contentView = final long start = Debug.threadCpuTimeNanos();
mEmbedder.getAnchorView().getRootView().findViewById(android.R.id.content); View contentView =
ViewUtils.getRelativeLayoutPosition(contentView, mAnchorView, mTempPosition); mEmbedder.getAnchorView().getRootView().findViewById(android.R.id.content);
int anchorY = mTempPosition[1]; ViewUtils.getRelativeLayoutPosition(contentView, mAnchorView, mTempPosition);
int anchorBottomRelativeToContent = anchorY + mAnchorView.getMeasuredHeight(); int anchorY = mTempPosition[1];
int anchorBottomRelativeToContent = anchorY + mAnchorView.getMeasuredHeight();
// Update the layout params to ensure the parent correctly positions the suggestions under // Update the layout params to ensure the parent correctly positions the suggestions
// the anchor view. // under the anchor view.
ViewGroup.LayoutParams layoutParams = getLayoutParams(); ViewGroup.LayoutParams layoutParams = getLayoutParams();
if (layoutParams != null && layoutParams instanceof MarginLayoutParams) { if (layoutParams != null && layoutParams instanceof MarginLayoutParams) {
((MarginLayoutParams) layoutParams).topMargin = anchorBottomRelativeToContent; ((MarginLayoutParams) layoutParams).topMargin = anchorBottomRelativeToContent;
} }
mEmbedder.getWindowDelegate().getWindowVisibleDisplayFrame(mTempRect); mEmbedder.getWindowDelegate().getWindowVisibleDisplayFrame(mTempRect);
int availableViewportHeight = mTempRect.height() - anchorBottomRelativeToContent; int availableViewportHeight = mTempRect.height() - anchorBottomRelativeToContent;
super.onMeasure( super.onMeasure(MeasureSpec.makeMeasureSpec(
MeasureSpec.makeMeasureSpec(mAnchorView.getMeasuredWidth(), MeasureSpec.EXACTLY), mAnchorView.getMeasuredWidth(), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(availableViewportHeight, MeasureSpec.makeMeasureSpec(availableViewportHeight,
mEmbedder.isTablet() ? MeasureSpec.AT_MOST : MeasureSpec.EXACTLY)); mEmbedder.isTablet() ? MeasureSpec.AT_MOST : MeasureSpec.EXACTLY));
final long end = Debug.threadCpuTimeNanos(); final long end = Debug.threadCpuTimeNanos();
SuggestionsMetrics.recordSuggestionListMeasureTime(start, end); SuggestionsMetrics.recordSuggestionListMeasureTime(start, end);
}
} }
@Override @Override
...@@ -224,10 +227,12 @@ public class OmniboxSuggestionsList extends ListView { ...@@ -224,10 +227,12 @@ public class OmniboxSuggestionsList extends ListView {
@Override @Override
protected void onLayout(boolean changed, int l, int t, int r, int b) { protected void onLayout(boolean changed, int l, int t, int r, int b) {
final long start = Debug.threadCpuTimeNanos(); try (TraceEvent tracing = TraceEvent.scoped("OmniboxSuggestionsList.Layout")) {
super.onLayout(changed, l, t, r, b); final long start = Debug.threadCpuTimeNanos();
final long end = Debug.threadCpuTimeNanos(); super.onLayout(changed, l, t, r, b);
SuggestionsMetrics.recordSuggestionListLayoutTime(start, end); final long end = Debug.threadCpuTimeNanos();
SuggestionsMetrics.recordSuggestionListLayoutTime(start, end);
}
} }
@Override @Override
......
...@@ -8,6 +8,7 @@ import android.os.Debug; ...@@ -8,6 +8,7 @@ import android.os.Debug;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import org.chromium.base.TraceEvent;
import org.chromium.ui.modelutil.ModelListAdapter; import org.chromium.ui.modelutil.ModelListAdapter;
/** /**
...@@ -27,10 +28,13 @@ class OmniboxSuggestionsListAdapter extends ModelListAdapter { ...@@ -27,10 +28,13 @@ class OmniboxSuggestionsListAdapter extends ModelListAdapter {
@Override @Override
protected View createView(ViewGroup parent, int typeId) { protected View createView(ViewGroup parent, int typeId) {
final long start = Debug.threadCpuTimeNanos(); try (TraceEvent tracing =
View v = super.createView(parent, typeId); TraceEvent.scoped("OmniboxSuggestionsList.CreateView", "type:" + typeId)) {
final long end = Debug.threadCpuTimeNanos(); final long start = Debug.threadCpuTimeNanos();
SuggestionsMetrics.recordSuggestionViewCreateTime(start, end); View v = super.createView(parent, typeId);
return v; final long end = Debug.threadCpuTimeNanos();
SuggestionsMetrics.recordSuggestionViewCreateTime(start, end);
return v;
}
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment