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

perf check #698

Merged
merged 3 commits into from
Aug 31, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,6 @@ public class ConstraintLayout extends ViewGroup {
private static final boolean USE_CONSTRAINTS_HELPER = true;
private static final boolean DEBUG = LinearSystem.FULL_DEBUG;
private static final boolean DEBUG_DRAW_CONSTRAINTS = false;
private static final boolean MEASURE = false;
private static final boolean OPTIMIZE_HEIGHT_CHANGE = false;

SparseArray<View> mChildrenByIds = new SparseArray<>();
Expand Down Expand Up @@ -741,10 +740,11 @@ public final void measure(ConstraintWidget widget,
return;
}

long startMeasure;
long startMeasure = 0;
long endMeasure;

if (MEASURE) {
if (mMetrics != null) {
mMetrics.mNumberOfMeasures++;
startMeasure = System.nanoTime();
}

Expand Down Expand Up @@ -1008,11 +1008,9 @@ && isSimilarSpec(widget.getLastVerticalMeasureSpec(),
measure.measuredHeight = height;
measure.measuredHasBaseline = hasBaseline;
measure.measuredBaseline = baseline;
if (MEASURE) {
if (mMetrics != null) {
endMeasure = System.nanoTime();
if (mMetrics != null) {
mMetrics.measuresWidgetsDuration += (endMeasure - startMeasure);
}
mMetrics.measuresWidgetsDuration += (endMeasure - startMeasure);
}
}

Expand Down Expand Up @@ -1736,6 +1734,7 @@ protected void resolveSystem(ConstraintWidgetContainer layout,
heightSize -= paddingHeight;

setSelfDimensionBehaviour(layout, widthMode, widthSize, heightMode, heightSize);

layout.measure(optimizationLevel, widthMode, widthSize, heightMode, heightSize,
mLastMeasureWidth, mLastMeasureHeight, paddingX, paddingY);
}
Expand Down Expand Up @@ -1788,8 +1787,10 @@ protected void resolveMeasuredDimension(int widthMeasureSpec,
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
long time = 0;
if (DEBUG) {
time = System.currentTimeMillis();
if (mMetrics != null) {
time = System.nanoTime();
mMetrics.mChildCount = getChildCount();
mMetrics.mMeasureCalls++;
}
mDirtyHierarchy |= dynamicUpdateConstraints(widthMeasureSpec, heightMeasureSpec);

Expand Down Expand Up @@ -1827,6 +1828,9 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
mLayoutWidget.getWidth(), mLayoutWidget.getHeight(),
mLayoutWidget.isWidthMeasuredTooSmall(),
mLayoutWidget.isHeightMeasuredTooSmall());
if (mMetrics != null) {
mMetrics.mMeasureDuration += System.nanoTime() - time;
}
return;
}
if (OPTIMIZE_HEIGHT_CHANGE
Expand All @@ -1847,6 +1851,9 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
mLayoutWidget.getWidth(), mLayoutWidget.getHeight(),
mLayoutWidget.isWidthMeasuredTooSmall(),
mLayoutWidget.isHeightMeasuredTooSmall());
if (mMetrics != null) {
mMetrics.mMeasureDuration += System.nanoTime() - time;
}
return;
}
}
Expand All @@ -1869,14 +1876,18 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
mLayoutWidget.updateHierarchy();
}
}
mLayoutWidget.fillMetrics(mMetrics);

resolveSystem(mLayoutWidget, mOptimizationLevel, widthMeasureSpec, heightMeasureSpec);
resolveMeasuredDimension(widthMeasureSpec, heightMeasureSpec,
mLayoutWidget.getWidth(), mLayoutWidget.getHeight(),
mLayoutWidget.isWidthMeasuredTooSmall(), mLayoutWidget.isHeightMeasuredTooSmall());

if (mMetrics != null) {
mMetrics.mMeasureDuration += System.nanoTime() - time;
}
if (DEBUG) {
time = System.currentTimeMillis() - time;
time = System.nanoTime() - time;
System.out.println(mLayoutWidget.getDebugName() + " (" + getChildCount()
+ ") DONE onMeasure width: " + MeasureSpec.toString(widthMeasureSpec)
+ " height: " + MeasureSpec.toString(heightMeasureSpec) + " => "
Expand Down Expand Up @@ -2008,6 +2019,9 @@ public void setState(int id, int screenWidth, int screenHeight) {
*/
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (mMetrics != null) {
mMetrics.mNumberOfLayouts++;
}
if (DEBUG) {
System.out.println(mLayoutWidget.getDebugName() + " onLayout changed: "
+ changed + " left: " + left + " top: " + top
Expand Down

This file was deleted.

Loading