* commit '6cb0aee42ebfe933ee7954508ba9273152011927': Consistently use weight to get average mem usage
This commit is contained in:
@@ -90,10 +90,10 @@ public class ProcStatsPackageEntry implements Parcelable {
|
|||||||
for (int i=0; i < N; i++) {
|
for (int i=0; i < N; i++) {
|
||||||
ProcStatsEntry entry = mEntries.get(i);
|
ProcStatsEntry entry = mEntries.get(i);
|
||||||
mBgDuration += entry.mBgDuration;
|
mBgDuration += entry.mBgDuration;
|
||||||
mAvgBgMem += entry.mAvgBgMem * entry.mBgDuration;
|
mAvgBgMem += entry.mAvgBgMem;
|
||||||
mBgWeight += entry.mBgWeight;
|
mBgWeight += entry.mBgWeight;
|
||||||
mRunDuration += entry.mRunDuration;
|
mRunDuration += entry.mRunDuration;
|
||||||
mAvgRunMem += entry.mAvgRunMem * entry.mRunDuration;
|
mAvgRunMem += entry.mAvgRunMem;
|
||||||
mRunWeight += entry.mRunWeight;
|
mRunWeight += entry.mRunWeight;
|
||||||
|
|
||||||
// Each entry is generally a process or something similar. Since it is extremely
|
// Each entry is generally a process or something similar. Since it is extremely
|
||||||
@@ -103,12 +103,8 @@ public class ProcStatsPackageEntry implements Parcelable {
|
|||||||
mMaxBgMem += entry.mMaxBgMem;
|
mMaxBgMem += entry.mMaxBgMem;
|
||||||
mMaxRunMem += entry.mMaxRunMem;
|
mMaxRunMem += entry.mMaxRunMem;
|
||||||
}
|
}
|
||||||
if (mBgDuration != 0) {
|
mAvgBgMem /= N;
|
||||||
mAvgBgMem = mAvgBgMem * N / mBgDuration;
|
mAvgRunMem /= N;
|
||||||
}
|
|
||||||
if (mRunDuration != 0) {
|
|
||||||
mAvgRunMem = mAvgRunMem * N / mRunDuration;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void retrieveUiData(Context context, PackageManager pm) {
|
public void retrieveUiData(Context context, PackageManager pm) {
|
||||||
|
@@ -86,7 +86,7 @@ public class ProcessStatsDetail extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
private LinearColorBar mColorBar;
|
private LinearColorBar mColorBar;
|
||||||
|
|
||||||
private float mMaxMemoryUsage;
|
private double mMaxMemoryUsage;
|
||||||
|
|
||||||
private double mTotalScale;
|
private double mTotalScale;
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ public class ProcessStatsDetail extends SettingsPreferenceFragment
|
|||||||
mUseUss = args.getBoolean(EXTRA_USE_USS);
|
mUseUss = args.getBoolean(EXTRA_USE_USS);
|
||||||
mWeightToRam = args.getDouble(EXTRA_WEIGHT_TO_RAM);
|
mWeightToRam = args.getDouble(EXTRA_WEIGHT_TO_RAM);
|
||||||
mTotalTime = args.getLong(EXTRA_TOTAL_TIME);
|
mTotalTime = args.getLong(EXTRA_TOTAL_TIME);
|
||||||
mMaxMemoryUsage = args.getFloat(EXTRA_MAX_MEMORY_USAGE);
|
mMaxMemoryUsage = args.getDouble(EXTRA_MAX_MEMORY_USAGE);
|
||||||
mTotalScale = args.getDouble(EXTRA_TOTAL_SCALE);
|
mTotalScale = args.getDouble(EXTRA_TOTAL_SCALE);
|
||||||
mOnePercentTime = mTotalTime/100;
|
mOnePercentTime = mTotalTime/100;
|
||||||
|
|
||||||
@@ -199,16 +199,17 @@ public class ProcessStatsDetail extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
// TODO: Find way to share this code with ProcessStatsPreference.
|
// TODO: Find way to share this code with ProcessStatsPreference.
|
||||||
boolean statsForeground = mApp.mRunWeight > mApp.mBgWeight;
|
boolean statsForeground = mApp.mRunWeight > mApp.mBgWeight;
|
||||||
float mAvgRatio = (statsForeground ? mApp.mAvgRunMem : mApp.mAvgBgMem) / mMaxMemoryUsage;
|
float avgRatio = (float) ((statsForeground ? mApp.mRunWeight : mApp.mBgWeight)
|
||||||
float mMaxRatio = (statsForeground ? mApp.mMaxRunMem : mApp.mMaxBgMem) / mMaxMemoryUsage
|
* mWeightToRam / mMaxMemoryUsage);
|
||||||
- mAvgRatio;
|
float maxRatio = (float) ((statsForeground ? mApp.mMaxRunMem : mApp.mMaxBgMem)
|
||||||
float mRemainingRatio = 1 - mAvgRatio - mMaxRatio;
|
* mTotalScale * 1024 / mMaxMemoryUsage - avgRatio);
|
||||||
|
float remainingRatio = 1 - avgRatio - maxRatio;
|
||||||
mColorBar = (LinearColorBar) headerLayout.findViewById(R.id.color_bar);
|
mColorBar = (LinearColorBar) headerLayout.findViewById(R.id.color_bar);
|
||||||
Context context = getActivity();
|
Context context = getActivity();
|
||||||
mColorBar.setColors(context.getColor(R.color.memory_avg_use),
|
mColorBar.setColors(context.getColor(R.color.memory_avg_use),
|
||||||
context.getColor(R.color.memory_max_use),
|
context.getColor(R.color.memory_max_use),
|
||||||
context.getColor(R.color.memory_remaining));
|
context.getColor(R.color.memory_remaining));
|
||||||
mColorBar.setRatios(mAvgRatio, mMaxRatio, mRemainingRatio);
|
mColorBar.setRatios(avgRatio, maxRatio, remainingRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@@ -58,7 +58,8 @@ public class ProcessStatsPreference extends Preference {
|
|||||||
mRemainingColor = context.getColor(R.color.memory_remaining);
|
mRemainingColor = context.getColor(R.color.memory_remaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(ProcStatsPackageEntry entry, PackageManager pm, float maxMemory) {
|
public void init(ProcStatsPackageEntry entry, PackageManager pm, double maxMemory,
|
||||||
|
double weightToRam, double totalScale) {
|
||||||
mEntry = entry;
|
mEntry = entry;
|
||||||
setTitle(TextUtils.isEmpty(entry.mUiLabel) ? entry.mPackage : entry.mUiLabel);
|
setTitle(TextUtils.isEmpty(entry.mUiLabel) ? entry.mPackage : entry.mUiLabel);
|
||||||
if (entry.mUiTargetApp != null) {
|
if (entry.mUiTargetApp != null) {
|
||||||
@@ -69,8 +70,10 @@ public class ProcessStatsPreference extends Preference {
|
|||||||
boolean statsForeground = entry.mRunWeight > entry.mBgWeight;
|
boolean statsForeground = entry.mRunWeight > entry.mBgWeight;
|
||||||
setSummary(entry.mRunDuration > entry.mBgDuration ? entry.getRunningFrequency(getContext())
|
setSummary(entry.mRunDuration > entry.mBgDuration ? entry.getRunningFrequency(getContext())
|
||||||
: entry.getBackgroundFrequency(getContext()));
|
: entry.getBackgroundFrequency(getContext()));
|
||||||
mAvgRatio = (statsForeground ? entry.mAvgRunMem : entry.mAvgBgMem) / maxMemory;
|
mAvgRatio = (float) ((statsForeground ? entry.mRunWeight : entry.mBgWeight)
|
||||||
mMaxRatio = (statsForeground ? entry.mMaxRunMem : entry.mMaxBgMem) / maxMemory - mAvgRatio;
|
* weightToRam / maxMemory);
|
||||||
|
mMaxRatio = (float) ((statsForeground ? entry.mMaxRunMem : entry.mMaxBgMem)
|
||||||
|
* totalScale * 1024 / maxMemory - mAvgRatio);
|
||||||
mRemainingRatio = 1 - mAvgRatio - mMaxRatio;
|
mRemainingRatio = 1 - mAvgRatio - mMaxRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -74,16 +74,12 @@ public class ProcessStatsUi extends InstrumentedPreferenceFragment {
|
|||||||
= new Comparator<ProcStatsPackageEntry>() {
|
= new Comparator<ProcStatsPackageEntry>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(ProcStatsPackageEntry lhs, ProcStatsPackageEntry rhs) {
|
public int compare(ProcStatsPackageEntry lhs, ProcStatsPackageEntry rhs) {
|
||||||
if (lhs.mRunWeight < rhs.mRunWeight) {
|
double rhsWeight = Math.max(rhs.mRunWeight, rhs.mBgWeight);
|
||||||
return 1;
|
double lhsWeight = Math.max(lhs.mRunWeight, lhs.mBgWeight);
|
||||||
} else if (lhs.mRunWeight > rhs.mRunWeight) {
|
if (lhsWeight == rhsWeight) {
|
||||||
return -1;
|
return 0;
|
||||||
} else if (lhs.mRunDuration < rhs.mRunDuration) {
|
|
||||||
return 1;
|
|
||||||
} else if (lhs.mRunDuration > rhs.mRunDuration) {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return lhsWeight < rhsWeight ? 1 : -1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -128,7 +124,7 @@ public class ProcessStatsUi extends InstrumentedPreferenceFragment {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private ProcStatsData mStatsManager;
|
private ProcStatsData mStatsManager;
|
||||||
private float mMaxMemoryUsage;
|
private double mMaxMemoryUsage;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
@@ -200,7 +196,7 @@ public class ProcessStatsUi extends InstrumentedPreferenceFragment {
|
|||||||
args.putDouble(ProcessStatsDetail.EXTRA_WEIGHT_TO_RAM,
|
args.putDouble(ProcessStatsDetail.EXTRA_WEIGHT_TO_RAM,
|
||||||
mStatsManager.getMemInfo().weightToRam);
|
mStatsManager.getMemInfo().weightToRam);
|
||||||
args.putLong(ProcessStatsDetail.EXTRA_TOTAL_TIME, memTotalTime);
|
args.putLong(ProcessStatsDetail.EXTRA_TOTAL_TIME, memTotalTime);
|
||||||
args.putFloat(ProcessStatsDetail.EXTRA_MAX_MEMORY_USAGE, mMaxMemoryUsage);
|
args.putDouble(ProcessStatsDetail.EXTRA_MAX_MEMORY_USAGE, mMaxMemoryUsage);
|
||||||
args.putDouble(ProcessStatsDetail.EXTRA_TOTAL_SCALE, mStatsManager.getMemInfo().totalScale);
|
args.putDouble(ProcessStatsDetail.EXTRA_TOTAL_SCALE, mStatsManager.getMemInfo().totalScale);
|
||||||
((SettingsActivity) getActivity()).startPreferencePanel(
|
((SettingsActivity) getActivity()).startPreferencePanel(
|
||||||
ProcessStatsDetail.class.getName(), args, R.string.details_title, null, null, 0);
|
ProcessStatsDetail.class.getName(), args, R.string.details_title, null, null, 0);
|
||||||
@@ -422,7 +418,7 @@ public class ProcessStatsUi extends InstrumentedPreferenceFragment {
|
|||||||
for (int i=0, N=pkgEntries.size(); i<N; i++) {
|
for (int i=0, N=pkgEntries.size(); i<N; i++) {
|
||||||
ProcStatsPackageEntry pkg = pkgEntries.get(i);
|
ProcStatsPackageEntry pkg = pkgEntries.get(i);
|
||||||
pkg.updateMetrics();
|
pkg.updateMetrics();
|
||||||
float maxMem = Math.max(pkg.mMaxBgMem, pkg.mMaxRunMem);
|
double maxMem = Math.max(pkg.mMaxBgMem, pkg.mMaxRunMem) * 1024 * memInfo.totalScale;
|
||||||
if (maxMem > mMaxMemoryUsage) {
|
if (maxMem > mMaxMemoryUsage) {
|
||||||
mMaxMemoryUsage = maxMem;
|
mMaxMemoryUsage = maxMem;
|
||||||
}
|
}
|
||||||
@@ -452,7 +448,7 @@ public class ProcessStatsUi extends InstrumentedPreferenceFragment {
|
|||||||
ProcStatsPackageEntry pkg = pkgEntries.get(i);
|
ProcStatsPackageEntry pkg = pkgEntries.get(i);
|
||||||
ProcessStatsPreference pref = new ProcessStatsPreference(context);
|
ProcessStatsPreference pref = new ProcessStatsPreference(context);
|
||||||
pkg.retrieveUiData(context, mPm);
|
pkg.retrieveUiData(context, mPm);
|
||||||
pref.init(pkg, mPm, mMaxMemoryUsage);
|
pref.init(pkg, mPm, mMaxMemoryUsage, memInfo.weightToRam, memInfo.totalScale);
|
||||||
pref.setOrder(i);
|
pref.setOrder(i);
|
||||||
mAppListGroup.addPreference(pref);
|
mAppListGroup.addPreference(pref);
|
||||||
if (mAppListGroup.getPreferenceCount() > (MAX_ITEMS_TO_LIST+1)) {
|
if (mAppListGroup.getPreferenceCount() > (MAX_ITEMS_TO_LIST+1)) {
|
||||||
|
Reference in New Issue
Block a user