Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit edf84cc

Browse files
committed
resolve comments
1 parent 0b849d3 commit edf84cc

File tree

5 files changed

+50
-15
lines changed

5 files changed

+50
-15
lines changed

constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintLayout.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
17901790
if (mMetrics != null) {
17911791
time = System.nanoTime();
17921792
mMetrics.mChildCount = getChildCount();
1793-
mMetrics.mMeasureCalls ++;
1793+
mMetrics.mMeasureCalls++;
17941794
}
17951795
mDirtyHierarchy |= dynamicUpdateConstraints(widthMeasureSpec, heightMeasureSpec);
17961796

constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintLayoutStatistics.java

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,17 @@ public ConstraintLayoutStatistics clone() {
9999
return new ConstraintLayoutStatistics(this);
100100
}
101101

102-
private String fmt(DecimalFormat df, float val, int sp) {
103-
String s = new String(new char[sp]).replace('\0', ' ');
102+
/**
103+
* Format a float value outputting a string of fixed length
104+
* @param df format to use
105+
* @param val
106+
* @param length
107+
* @return
108+
*/
109+
private String fmt(DecimalFormat df, float val, int length) {
110+
String s = new String(new char[length]).replace('\0', ' ');
104111
s = (s + df.format(val));
105-
return s.substring(s.length() - sp);
112+
return s.substring(s.length() - length);
106113
}
107114

108115
/**
@@ -134,6 +141,12 @@ private void log(String tag) {
134141
Log.v(tag, log( NUMBER_OF_SIMPLE_EQUATIONS));
135142
}
136143

144+
/**
145+
* Generate a formatted String for the parameter formatting as a float
146+
* @param df
147+
* @param param
148+
* @return
149+
*/
137150
private String log(DecimalFormat df, int param) {
138151
String value = fmt(df, getValue(param) * 1E-6f, 7);
139152

@@ -143,6 +156,12 @@ private String log(DecimalFormat df, int param) {
143156
title += " = ";
144157
return "CL Perf: " + title + value;
145158
}
159+
160+
/**
161+
* Generate a formatted String for the parameter
162+
* @param param
163+
* @return
164+
*/
146165
private String log(int param) {
147166
String value = Long.toString(this.getValue(param));
148167
String title = geName(param);
@@ -152,6 +171,13 @@ private String log(int param) {
152171
return "CL Perf: " + title + value;
153172
}
154173

174+
/**
175+
* Generate a float formatted String for the parameter comparing current value with value in relative
176+
* @param df Format the float using this
177+
* @param relative compare against
178+
* @param param the parameter to compare
179+
* @return
180+
*/
155181
private String compare(DecimalFormat df, ConstraintLayoutStatistics relative, int param) {
156182
String value = fmt(df, getValue(param) * 1E-6f, 7);
157183
value += " -> " + fmt(df, relative.getValue(param) * 1E-6f, 7) + "ms";
@@ -162,6 +188,12 @@ private String compare(DecimalFormat df, ConstraintLayoutStatistics relative, i
162188
return "CL Perf: " + title + value;
163189
}
164190

191+
/**
192+
* Generate a formatted String for the parameter comparing current value with value in relative
193+
* @param relative compare against
194+
* @param param the parameter to compare
195+
* @return
196+
*/
165197
private String compare(ConstraintLayoutStatistics relative, int param) {
166198
String value = this.getValue(param) + " -> " + relative.getValue(param);
167199
String title = geName(param);

constraintlayout/core/src/main/java/androidx/constraintlayout/core/LinearSystem.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public class LinearSystem {
3131
public static final boolean FULL_DEBUG = false;
3232
public static final boolean DEBUG = false;
3333
private static final boolean DO_NOT_USE = false;
34-
// public static final boolean MEASURE = false;
3534

3635
private static final boolean DEBUG_CONSTRAINTS = FULL_DEBUG;
3736

constraintlayout/core/src/main/java/androidx/constraintlayout/core/Metrics.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ public class Metrics {
6464
public long mMeasureDuration; // time spent in measure in nanoseconds
6565
public long mChildCount; // number of child Views of ConstraintLayout
6666
public long mMeasureCalls; // number of time CL onMeasure is called
67-
public long mSolverPasses;
68-
public long mEquations;
69-
public long mVariables;
67+
public long mSolverPasses;
68+
public long mEquations;
69+
public long mVariables;
7070
public long mSimpleEquations;
7171

7272
// @TODO: add description
@@ -126,15 +126,19 @@ public void reset() {
126126
mEquations = 0;
127127
mSimpleEquations = 0;
128128
}
129-
129+
130+
/**
131+
* Copy the values from and existing Metrics class
132+
* @param metrics
133+
*/
130134
public void copy(Metrics metrics) {
131135
mVariables = metrics.mVariables;
132136
mEquations = metrics.mEquations;
133137
mSimpleEquations = metrics.mSimpleEquations;
134138
mNumberOfMeasures = metrics.mNumberOfMeasures;
135139
mNumberOfLayouts = metrics.mNumberOfLayouts;
136140
mMeasureDuration = metrics.mMeasureDuration;
137-
mChildCount = metrics.mChildCount;
141+
mChildCount = metrics.mChildCount;
138142
mMeasureCalls = metrics.mMeasureCalls;
139143
measuresWidgetsDuration = metrics.measuresWidgetsDuration;
140144
mSolverPasses = metrics.mSolverPasses;

projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/CheckPerformanceMetric.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
*/
3333
public class CheckPerformanceMetric extends AppCompatActivity {
3434
private static final String TAG = "CheckPerformanceMetric";
35-
String layout_name;
36-
ConstraintLayout mConstraintLayout;
37-
ConstraintLayoutStatistics performance;
38-
ConstraintLayoutStatistics prePerformance;
39-
int loop;
35+
String layout_name = null;
36+
ConstraintLayout mConstraintLayout = null;
37+
ConstraintLayoutStatistics performance = null;
38+
ConstraintLayoutStatistics prePerformance = null;
39+
int loop = 0;
4040

4141
@Override
4242
protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {

0 commit comments

Comments
 (0)