blob: 62f427194646271f9905d17274bd24bc1341648b [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17import java.io.IOException;
18import java.io.FileInputStream;
19import java.io.ObjectInputStream;
20import java.io.BufferedInputStream;
Bob Lee2e93f652009-08-11 01:16:03 -070021import java.util.Set;
22import java.util.HashSet;
23import java.util.TreeSet;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024
25/**
26 * Prints raw information in CSV format.
27 */
28public class PrintCsv {
29
30 public static void main(String[] args)
31 throws IOException, ClassNotFoundException {
32 if (args.length != 1) {
33 System.err.println("Usage: PrintCsv [compiled log file]");
34 System.exit(0);
35 }
36
37 Root root = Root.fromFile(args[0]);
38
39 System.out.println("Name"
40 + ",Preloaded"
41 + ",Median Load Time (us)"
42 + ",Median Init Time (us)"
Bob Lee2e93f652009-08-11 01:16:03 -070043 + ",Process Names"
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044 + ",Load Count"
Bob Lee2e93f652009-08-11 01:16:03 -070045 + ",Init Count");
46// + ",Managed Heap (B)"
47// + ",Native Heap (B)"
48// + ",Managed Pages (kB)"
49// + ",Native Pages (kB)"
50// + ",Other Pages (kB)");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080051
52 MemoryUsage baseline = root.baseline;
53
54 for (LoadedClass loadedClass : root.loadedClasses.values()) {
55 if (!loadedClass.systemClass) {
56 continue;
57 }
58
59 System.out.print(loadedClass.name);
60 System.out.print(',');
61 System.out.print(loadedClass.preloaded);
62 System.out.print(',');
63 System.out.print(loadedClass.medianLoadTimeMicros());
64 System.out.print(',');
65 System.out.print(loadedClass.medianInitTimeMicros());
66 System.out.print(',');
Bob Lee2e93f652009-08-11 01:16:03 -070067 System.out.print('"');
68
69 Set<String> procNames = new TreeSet<String>();
70 for (Operation op : loadedClass.loads)
71 procNames.add(op.process.name);
72 for (Operation op : loadedClass.initializations)
73 procNames.add(op.process.name);
74 for (String name : procNames) {
75 System.out.print(name + "\n");
76 }
77
78 System.out.print('"');
79 System.out.print(',');
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080080 System.out.print(loadedClass.loads.size());
81 System.out.print(',');
82 System.out.print(loadedClass.initializations.size());
Bob Lee2e93f652009-08-11 01:16:03 -070083/*
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080084 if (loadedClass.memoryUsage.isAvailable()) {
85 MemoryUsage subtracted
86 = loadedClass.memoryUsage.subtract(baseline);
87
88 System.out.print(',');
89 System.out.print(subtracted.javaHeapSize());
90 System.out.print(',');
91 System.out.print(subtracted.nativeHeapSize);
92 System.out.print(',');
93 System.out.print(subtracted.javaPagesInK());
94 System.out.print(',');
95 System.out.print(subtracted.nativePagesInK());
96 System.out.print(',');
97 System.out.print(subtracted.otherPagesInK());
98
99 } else {
100 System.out.print(",n/a,n/a,n/a,n/a,n/a");
101 }
Bob Lee2e93f652009-08-11 01:16:03 -0700102*/
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800103 System.out.println();
104 }
105 }
106}