summaryrefslogtreecommitdiffstats
path: root/tools/preload/Proc.java
diff options
context:
space:
mode:
Diffstat (limited to 'tools/preload/Proc.java')
-rw-r--r--tools/preload/Proc.java76
1 files changed, 4 insertions, 72 deletions
diff --git a/tools/preload/Proc.java b/tools/preload/Proc.java
index 66e04dc..2105021 100644
--- a/tools/preload/Proc.java
+++ b/tools/preload/Proc.java
@@ -14,13 +14,11 @@
* limitations under the License.
*/
-import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Map;
import java.util.HashMap;
-import java.util.Collections;
import java.io.Serializable;
/**
@@ -30,11 +28,6 @@ class Proc implements Serializable {
private static final long serialVersionUID = 0;
- /**
- * Default percentage of time to cut off of app class loading times.
- */
- static final int PERCENTAGE_TO_PRELOAD = 75;
-
/** Parent process. */
final Proc parent;
@@ -80,72 +73,11 @@ class Proc implements Serializable {
}
/**
- * Returns the percentage of time we should cut by preloading for this
- * app.
- */
- int percentageToPreload() {
- return PERCENTAGE_TO_PRELOAD;
- }
-
- /**
- * Returns a list of classes which should be preloaded.
+ * Returns true if this process comes from the zygote.
*/
- List<LoadedClass> highestRankedClasses() {
- if (!isApplication() || Policy.isService(this.name)) {
- return Collections.emptyList();
- }
-
- // Sort by rank.
- Operation[] ranked = new Operation[operations.size()];
- ranked = operations.toArray(ranked);
- Arrays.sort(ranked, new ClassRank());
-
- // The percentage of time to save by preloading.
- int timeToSave = totalTimeMicros() * percentageToPreload() / 100;
- int timeSaved = 0;
-
- int count = 0;
- List<LoadedClass> highest = new ArrayList<LoadedClass>();
- for (Operation operation : ranked) {
- if (timeSaved >= timeToSave || count++ > 100) {
- break;
- }
-
- if (!Policy.isPreloadableClass(operation.loadedClass.name)) {
- continue;
- }
-
- if (!operation.loadedClass.systemClass) {
- continue;
- }
-
- highest.add(operation.loadedClass);
- timeSaved += operation.medianExclusiveTimeMicros();
- }
-
- return highest;
- }
-
- /**
- * Total time spent class loading and initializing.
- */
- int totalTimeMicros() {
- int totalTime = 0;
- for (Operation operation : operations) {
- totalTime += operation.medianExclusiveTimeMicros();
- }
- return totalTime;
- }
-
- /**
- * Returns true if this process is an app.
- */
- public boolean isApplication() {
- if (name.equals("com.android.development")) {
- return false;
- }
-
- return parent != null && parent.name.equals("zygote");
+ public boolean fromZygote() {
+ return parent != null && parent.name.equals("zygote")
+ && !name.equals("com.android.development");
}
/**