The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | import java.io.IOException; |
| 18 | import java.io.FileInputStream; |
| 19 | import java.io.ObjectInputStream; |
| 20 | import java.io.BufferedInputStream; |
| 21 | |
| 22 | /** |
| 23 | * Prints raw information in CSV format. |
| 24 | */ |
| 25 | public class PrintCsv { |
| 26 | |
| 27 | public static void main(String[] args) |
| 28 | throws IOException, ClassNotFoundException { |
| 29 | if (args.length != 1) { |
| 30 | System.err.println("Usage: PrintCsv [compiled log file]"); |
| 31 | System.exit(0); |
| 32 | } |
| 33 | |
| 34 | Root root = Root.fromFile(args[0]); |
| 35 | |
| 36 | System.out.println("Name" |
| 37 | + ",Preloaded" |
| 38 | + ",Median Load Time (us)" |
| 39 | + ",Median Init Time (us)" |
| 40 | + ",Load Count" |
| 41 | + ",Init Count" |
| 42 | + ",Managed Heap (B)" |
| 43 | + ",Native Heap (B)" |
| 44 | + ",Managed Pages (kB)" |
| 45 | + ",Native Pages (kB)" |
| 46 | + ",Other Pages (kB)"); |
| 47 | |
| 48 | MemoryUsage baseline = root.baseline; |
| 49 | |
| 50 | for (LoadedClass loadedClass : root.loadedClasses.values()) { |
| 51 | if (!loadedClass.systemClass) { |
| 52 | continue; |
| 53 | } |
| 54 | |
| 55 | System.out.print(loadedClass.name); |
| 56 | System.out.print(','); |
| 57 | System.out.print(loadedClass.preloaded); |
| 58 | System.out.print(','); |
| 59 | System.out.print(loadedClass.medianLoadTimeMicros()); |
| 60 | System.out.print(','); |
| 61 | System.out.print(loadedClass.medianInitTimeMicros()); |
| 62 | System.out.print(','); |
| 63 | System.out.print(loadedClass.loads.size()); |
| 64 | System.out.print(','); |
| 65 | System.out.print(loadedClass.initializations.size()); |
| 66 | |
| 67 | if (loadedClass.memoryUsage.isAvailable()) { |
| 68 | MemoryUsage subtracted |
| 69 | = loadedClass.memoryUsage.subtract(baseline); |
| 70 | |
| 71 | System.out.print(','); |
| 72 | System.out.print(subtracted.javaHeapSize()); |
| 73 | System.out.print(','); |
| 74 | System.out.print(subtracted.nativeHeapSize); |
| 75 | System.out.print(','); |
| 76 | System.out.print(subtracted.javaPagesInK()); |
| 77 | System.out.print(','); |
| 78 | System.out.print(subtracted.nativePagesInK()); |
| 79 | System.out.print(','); |
| 80 | System.out.print(subtracted.otherPagesInK()); |
| 81 | |
| 82 | } else { |
| 83 | System.out.print(",n/a,n/a,n/a,n/a,n/a"); |
| 84 | } |
| 85 | |
| 86 | System.out.println(); |
| 87 | } |
| 88 | } |
| 89 | } |