From: Lukas P. <pe...@us...> - 2002-02-08 10:13:23
|
Update of /cvsroot/javaprofiler/test/snapshot In directory usw-pr-cvs1:/tmp/cvs-serv1802 Added Files: DebugOutput.java Log Message: moved from jpiimpl module --- NEW FILE: DebugOutput.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License Version * 1.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is available at http://www.sun.com/ * * The Original Code is the Java Profiler module. * The Initial Developers of the Original Code are Jan Stola, Pavel Vacha, * Michal Pise, Petr Luner, Lukas Petru and Marek Przeczek. * Portions created by Jan Stola are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Pavel Vacha are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Michal Pise are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Petr Luner are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Lukas Petru are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Marek Przeczek are Copyright (C) 2000-2001. All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ import java.util.*; import net.sourceforge.javaprofiler.jpiimpl.data.*; import net.sourceforge.javaprofiler.jpiimpl.commun.IProf; /** Sample class that prints Snapshot data in textual form. */ public class DebugOutput { /** Print snapshot data to System.out. * @param sn SnapshotImpl data to print. */ public static void print (SnapshotImpl sn) { // classes list, ClassData object type Iterator it = sn.classes().iterator(); while (it.hasNext()) { ClassData c = (ClassData) it.next(); System.out.println("CLASS = " + c.getName()); System.out.println(); System.out.println("METHODS:"); Iterator itM = c.getMethods().iterator(); while (itM.hasNext()) { MethodData m = (MethodData) itM.next(); System.out.println(m.getName() + " SIGN = " + m.getSignature() ); System.out.println(); } System.out.println("INSTANCE FIELDS:"); Iterator itI = c.getInstanceFields().iterator(); while (itI.hasNext()) { ClassFieldData f = (ClassFieldData) itI.next(); System.out.println(f.getName() + " SIGN = " + f.getSignature() ); System.out.println(); } System.out.println("STATIC FIELDS:"); Iterator itS = c.getStaticFields().iterator(); while (itS.hasNext()) { ClassFieldData f = (ClassFieldData) itS.next(); System.out.println(f.getName() + " SIGN = " + f.getSignature() ); System.out.println(); } } // groupThreads list, ThreadGroupData object type it = sn.groupOfThreads().iterator(); while (it.hasNext()) { ThreadGroupData g = (ThreadGroupData) it.next(); System.out.println("GROUP = " + g.getName()); Iterator itT = g.getThreads().iterator(); while (itT.hasNext()) { ThreadData th = (ThreadData) itT.next(); System.out.println(th.getName() + " : "); } } // objectTypes list, AllocClassData object type it = sn.allocObjects().iterator(); while (it.hasNext()) { AllocClassData o = (AllocClassData) it.next(); System.out.println("OBJECT TYPE:"); ClassData c = o.getClassData(); if (c != null) System.out.println("CLASS = " + c.getName()); System.out.println("IS_ARRAY = "); String s; switch (o.getType()) { case IProf.JVMPI_NORMAL_OBJECT: s = "JVMPI_NORMAL_OBJECT"; break; case IProf.JVMPI_CLASS: s = "JVMPI_CLASS"; break; case IProf.JVMPI_BOOLEAN: s = "JVMPI_BOOLEAN"; break; case IProf.JVMPI_BYTE: s = "JVMPI_BYTE"; break; case IProf.JVMPI_CHAR: s = "JVMPI_CHAR"; break; case IProf.JVMPI_SHORT: s = "JVMPI_SHORT"; break; case IProf.JVMPI_INT: s = "JVMPI_INT"; break; case IProf.JVMPI_LONG: s = "JVMPI_LONG"; break; case IProf.JVMPI_FLOAT: s = "JVMPI_FLOAT"; break; case IProf.JVMPI_DOUBLE: s = "JVMPI_DOUBLE"; break; default: s = null; break; } System.out.println(s); System.out.println(); } // arenas list, AllocArenaData object type // FIX arenas() it = sn.arenas().iterator(); while (it.hasNext()) { AllocArenaData a = (AllocArenaData) it.next(); System.out.println("ARENA = " + a.getName()); System.out.println(); } // instances are N/A from IProf! // leaving blank // gcs list, GCData object type // FIX gcs() it = sn.gcs().iterator(); while (it.hasNext()) { GCData g = (GCData) it.next(); System.out.println("GC:"); System.out.println("start: " + g.getStartTime()); System.out.println("end: " + g.getEndTime()); } // jniGlobalRefs and jniWeakGlobalRefs are N/A from IProf! // leaving blank // Hash Statistics are N/A. // leaving blank // Total summary int totalClasses = 0; int totalMethods = 0; int totalAllocTraces = 0; int totalAllocObjects = 0; int totalAllocObjectMethods = 0; int totalAllocObjectTraces = 0; int totalThreads = 0; int totalAllocThreadObjects = 0; int totalAllocThreadObjectMethods = 0; int totalAllocThreadObjectTraces = 0; int totalAllocThreadMethods = 0; int totalAllocThreadTraces = 0; int totalCpuTraces = 0; int totalCpuThreadMethods = 0; int totalCpuThreadTraces = 0; int totalMonTraces = 0; int totalMonThreadMethods = 0; int totalMonThreadTraces = 0; it = sn.classes().iterator(); while (it.hasNext()) { ClassData c = (ClassData) it.next(); Iterator itM = c.getMethods().iterator(); while (itM.hasNext()) { MethodData m = (MethodData) itM.next(); Iterator itT = m.getAllocTraces().values().iterator(); while (itT.hasNext()) { AllocTraceData t = (AllocTraceData) itT.next(); totalAllocTraces ++; } itT = m.getCPUTraces().values().iterator(); while (itT.hasNext()) { CPUTraceData t = (CPUTraceData) itT.next(); totalCpuTraces ++; } itT = m.getMonTraces().values().iterator(); while (itT.hasNext()) { MonTraceData t = (MonTraceData) itT.next(); totalMonTraces ++; } totalMethods ++; } totalClasses ++; } it = sn.allocObjects().iterator(); while (it.hasNext()) { AllocClassData a = (AllocClassData) it.next(); Iterator itM = a.getMethods().values().iterator(); while (itM.hasNext()) { AllocClassMethodData m = (AllocClassMethodData) itM.next(); Iterator itT = m.getTraces().values().iterator(); while (itT.hasNext()) { AllocClassTraceData t = (AllocClassTraceData) itT.next(); totalAllocObjectTraces ++; } totalAllocObjectMethods ++; } totalAllocObjects ++; } it = sn.threads().iterator(); while (it.hasNext()) { ThreadData th = (ThreadData) it.next(); Iterator itA = th.getClasses().values().iterator(); while (itA.hasNext()) { AllocThreadClassData a = (AllocThreadClassData) itA.next(); Iterator itM = a.getMethods().values().iterator(); while (itM.hasNext()) { AllocThreadClassMethodData m = (AllocThreadClassMethodData) itM.next(); Iterator itT = m.getTraces().values().iterator(); while (itT.hasNext()) { AllocThreadClassTraceData t = (AllocThreadClassTraceData) itT.next(); totalAllocThreadObjectTraces ++; } totalAllocThreadObjectMethods ++; } totalAllocThreadObjects ++; } Iterator itM = th.getAllocMethods().values().iterator(); while (itM.hasNext()) { AllocThreadMethodData m = (AllocThreadMethodData) itM.next(); Iterator itT = m.getTraces().values().iterator(); while (itT.hasNext()) { AllocThreadTraceData t = (AllocThreadTraceData) itT.next(); totalAllocThreadTraces ++; } totalAllocThreadMethods ++; } itM = th.getCPUMethods().values().iterator(); while (itM.hasNext()) { CPUThreadMethodData m = (CPUThreadMethodData) itM.next(); Iterator itT = m.getTraces().values().iterator(); while (itT.hasNext()) { CPUThreadTraceData t = (CPUThreadTraceData) itT.next(); totalCpuThreadTraces ++; } totalCpuThreadMethods ++; } itM = th.getMonMethods().values().iterator(); while (itM.hasNext()) { MonThreadMethodData m = (MonThreadMethodData) itM.next(); Iterator itT = m. getTraces().values().iterator(); while (itT.hasNext()) { MonThreadTraceData t = (MonThreadTraceData) itT.next(); totalMonThreadTraces ++; } totalMonThreadMethods ++; } totalThreads ++; } System.out.println("TOTALS:"); System.out.println(); System.out.println("Classes: " + totalClasses); System.out.println("Methods: " + totalMethods); System.out.println("Threads: " + totalThreads); System.out.println(); System.out.println("AllocObject: " + totalAllocObjects); System.out.println("AllocThreadObject: " + totalAllocThreadObjects); System.out.println(); System.out.println("AllocObjectMethod: " + totalAllocObjectMethods); System.out.println("AllocThreadMethod: " + totalAllocThreadMethods); System.out.println("AllocThreadObjectMethod: " + totalAllocThreadObjectMethods); System.out.println(); System.out.println("AllocTrace: " + totalAllocTraces); System.out.println("AllocObjectTrace: " + totalAllocObjectTraces); System.out.println("AllocThreadTrace: " + totalAllocThreadTraces); System.out.println("AllocThreadObjectTrace: " + totalAllocThreadObjectTraces); System.out.println(); System.out.println("CpuThreadMethod: " + totalCpuThreadMethods); System.out.println(); System.out.println("CpuTrace: " + totalCpuTraces); System.out.println("CpuThreadTrace: " + totalCpuThreadTraces); System.out.println(); System.out.println("MonThreadMethod: " + totalMonThreadMethods); System.out.println(); System.out.println("MonTrace: " + totalMonTraces); System.out.println("MonThreadTrace: " + totalMonThreadTraces); System.out.println(); } } /* * $Log: DebugOutput.java,v $ * Revision 1.1 2002/02/08 10:13:20 petrul * moved from jpiimpl module * * Revision 1.1 2002/01/24 22:16:31 petrul * First version of DebugOutput * */ |