From: Pavel V. <va...@us...> - 2002-03-04 00:14:00
|
Update of /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/data In directory usw-pr-cvs1:/tmp/cvs-serv10884 Modified Files: SnapshotImpl.java Log Message: configuration class added Index: SnapshotImpl.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/data/SnapshotImpl.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** SnapshotImpl.java 3 Mar 2002 01:20:09 -0000 1.12 --- SnapshotImpl.java 4 Mar 2002 00:13:56 -0000 1.13 *************** *** 23,26 **** --- 23,27 ---- import java.util.*; + import java.io.Serializable; import net.sourceforge.javaprofiler.jpi.*; *************** *** 36,69 **** * @author Pavel Vacha */ ! public class SnapshotImpl implements Snapshot { private String name; private long time; ! private HashMap libIDs = new HashMap(); //converts libIds to references ! private LinkedList classes = new LinkedList(); ! private LinkedList methods = new LinkedList(); ! private LinkedList groupThreads = new LinkedList(); ! private LinkedList threads = new LinkedList(); ! private LinkedList allocTypes = new LinkedList(); ! private LinkedList arenas = new LinkedList(); ! private LinkedList gcs = new LinkedList(); ! ! //default conf ! private boolean withCPU = true; ! private boolean withAlloc = true; ! private boolean withMon = true; ! private boolean withTraces = true; ! private boolean withThreads = true; ! private boolean withArenas = true; ! private boolean withGC = true; ! //only traces with more hits than this will be extracted ! private int CPUTraces_MinVal = IProf.NO_OPTIONAL_ARG; //2; ! //only traces with more allocations than this will be extracted ! private int AllocTraces_MinVal = IProf.NO_OPTIONAL_ARG; //2; ! //only traces with more hits than this will be extracted ! private int MonTraces_MinVal = IProf.NO_OPTIONAL_ARG; //2; ! ! //other private boolean haveSnapshot = false; --- 37,92 ---- * @author Pavel Vacha */ ! public class SnapshotImpl implements Snapshot, Serializable { private String name; private long time; ! //PENDING //?transient ! private Map libIDs = new HashMap(); //converts libIds to references ! private List classes = new LinkedList(); ! private List methods = new LinkedList(); ! private List groupThreads = new LinkedList(); ! private List threads = new LinkedList(); ! private List allocTypes = new LinkedList(); ! private List arenas = new LinkedList(); ! private List gcs = new LinkedList(); ! ! private Configuration conf; ! ! /** Configuration object, you can tune you snaphot content. */ ! public static class Configuration implements Cloneable, Serializable { ! /** Whether include snapshot of CPU. */ ! public boolean withCPU = true; ! /** Whether include snapshot of allocations.*/ ! public boolean withAlloc = true; ! /** Whether include snapshot of monitors. */ ! public boolean withMon = true; ! /** Whether include even discrimination to traces. */ ! public boolean withTraces = true; ! /** Whether include discrimination to threads. */ ! public boolean withThreads = true; ! /** Whether inlucde snapshot of arenas. */ ! public boolean withArenas = true; ! /** Whether inlucde snapshot of garbage collector. */ ! public boolean withGC = true; ! /** Whether inlucde call tree */ ! public boolean withCallTree = true; ! /**Only traces with more hits than this will be extracted. ! Use <code>IProf.NO_OPTIONAL_ARG</code> for extraction of all traces.*/ ! public int CPUTraces_MinVal = IProf.NO_OPTIONAL_ARG; ! /**Only traces with more allocations than this will be extracted. ! Use <code>IProf.NO_OPTIONAL_ARG</code> for extraction of all traces.*/ ! public int AllocTraces_MinVal = IProf.NO_OPTIONAL_ARG; ! /**Only traces with more hits than this will be extracted. ! Use <code>IProf.NO_OPTIONAL_ARG</code> for extraction of all traces.*/ ! public int MonTraces_MinVal = IProf.NO_OPTIONAL_ARG; ! ! public Object clone() throws CloneNotSupportedException { ! return super.clone(); ! } ! ! } ! ! //other private boolean haveSnapshot = false; *************** *** 77,80 **** --- 100,104 ---- */ public SnapshotImpl( IProf iprof ) { + this.conf = new Configuration(); //default makeSnapshot( iprof ); } *************** *** 84,124 **** * *@param iprof Communacation object (you have to be connected to profiled VM). ! *@param withCPU Whether include snapshot of CPU. ! *@param withAlloc Whether include snapshot of allocations. ! *@param withMon Whether include snapshot of monitors. ! *@param withArenas Whether inlucde snapshot of arenas. ! *@param withGC Whether inlucde snapshot of garbage collector. ! * ! *@param withTraces Whether include even discrimination to traces. ! *@param withThreads Whether include discrimination to threads. ! * ! *@param CPUTraces_MinVal Only traces with more hits than this will be extracted. ! * Use <code>IProf.NO_OPTIONAL_ARG</code> for extraction of all traces. ! *@param AllocTraces_MinVal Only traces with more allocations than this will be extracted. ! * Use <code>IProf.NO_OPTIONAL_ARG</code> for extraction of all traces. ! *@param MonTraces_MinVal Only traces with more hits than this will be extracted. ! * Use <code>IProf.NO_OPTIONAL_ARG</code> for extraction of all traces. */ //maybe use some configuration object ! public SnapshotImpl( IProf iprof, boolean withCPU, boolean withAlloc, ! boolean withMon, boolean withTraces, ! boolean withThreads, boolean withArenas, boolean withGC, ! int CPUTraces_MinVal, ! int AllocTraces_MinVal, ! int MonTraces_MinVal ) { ! this.withCPU = withCPU; ! this.withAlloc = withAlloc; ! this.withMon = withMon; ! this.withTraces = withTraces; ! this.withThreads = withThreads; ! this.withGC = withGC; ! this.withArenas = withArenas; ! this.CPUTraces_MinVal = CPUTraces_MinVal; ! this.AllocTraces_MinVal = AllocTraces_MinVal; ! this.MonTraces_MinVal = MonTraces_MinVal; ! makeSnapshot( iprof ); } ! ////////////////////////////////////////////////////////////////////////// // implementation of Snapdhot interface --- 108,125 ---- * *@param iprof Communacation object (you have to be connected to profiled VM). ! *@param conf Configuration object, you can tune you snaphot content */ //maybe use some configuration object ! public SnapshotImpl( IProf iprof, Configuration conf ) { ! //PENDING ! try { ! this.conf = (Configuration) conf.clone(); ! makeSnapshot( iprof ); ! } catch( Exception e) { ! System.err.println( e ); ! } } ! ////////////////////////////////////////////////////////////////////////// // implementation of Snapdhot interface *************** *** 330,336 **** long start = System.currentTimeMillis(); ! LinkedList actLst = new LinkedList(); //temporary list ! LinkedList actLst2 = new LinkedList(); //temporary list ! LinkedList actLst3 = new LinkedList(); try { --- 331,337 ---- long start = System.currentTimeMillis(); ! List actLst = new LinkedList(); //temporary list ! List actLst2 = new LinkedList(); //temporary list ! List actLst3 = new LinkedList(); try { *************** *** 338,342 **** ! if (withCPU || withAlloc || withMon) { extract( null, classes, IProf.CLASSES, IProf.NO_OPTIONAL_ARG, iprof ); //get class fields --- 339,343 ---- ! if (conf.withCPU || conf.withAlloc || conf.withMon) { extract( null, classes, IProf.CLASSES, IProf.NO_OPTIONAL_ARG, iprof ); //get class fields *************** *** 345,349 **** //extract( classes, methods, IProf.CLASS_METHODS, IProf.NO_OPTIONAL_ARG, iprof ); extract( null, methods, IProf.METHODS, IProf.NO_OPTIONAL_ARG, iprof ); ! if( withThreads ) { extract( null, groupThreads, IProf.GROUPS_OF_THREADS, IProf.NO_OPTIONAL_ARG, iprof ); --- 346,350 ---- //extract( classes, methods, IProf.CLASS_METHODS, IProf.NO_OPTIONAL_ARG, iprof ); extract( null, methods, IProf.METHODS, IProf.NO_OPTIONAL_ARG, iprof ); ! if( conf.withThreads ) { extract( null, groupThreads, IProf.GROUPS_OF_THREADS, IProf.NO_OPTIONAL_ARG, iprof ); *************** *** 354,375 **** } } ! if( withCPU ) { ! if( withTraces ) { //extract( methods, null, IProf.CPU_METHOD_TRACES, // CPUTraces_MinVal, iprof ); extract( null, null, IProf.CPU_TRACES, ! CPUTraces_MinVal, iprof ); } ! if( withThreads ) { ! extract( threads, (withTraces) ? actLst : null, IProf.CPU_THREAD_METHODS, IProf.NO_OPTIONAL_ARG, iprof ); ! if( withTraces ) { extract( actLst, null, IProf.CPU_THREAD_METHOD_TRACES, ! CPUTraces_MinVal, iprof ); } } } ! if( withAlloc ) { actLst3.clear(); actLst2.clear(); --- 355,376 ---- } } ! if( conf.withCPU ) { ! if( conf.withTraces ) { //extract( methods, null, IProf.CPU_METHOD_TRACES, // CPUTraces_MinVal, iprof ); extract( null, null, IProf.CPU_TRACES, ! conf.CPUTraces_MinVal, iprof ); } ! if( conf.withThreads ) { ! extract( threads, (conf.withTraces) ? actLst : null, IProf.CPU_THREAD_METHODS, IProf.NO_OPTIONAL_ARG, iprof ); ! if( conf.withTraces ) { extract( actLst, null, IProf.CPU_THREAD_METHOD_TRACES, ! conf.CPUTraces_MinVal, iprof ); } } } ! if( conf.withAlloc ) { actLst3.clear(); actLst2.clear(); *************** *** 377,392 **** extract( null, allocTypes, IProf.OBJECT_TYPES, IProf.NO_OPTIONAL_ARG, iprof ); ! extract( allocTypes, (withTraces)? actLst : null, IProf.ALLOC_OBJECT_METHODS, IProf.NO_OPTIONAL_ARG, iprof ); ! if( withTraces ) { //extract( methods, null, IProf.ALLOC_METHOD_TRACES, // AllocTraces_MinVal, iprof ); extract( null, null, IProf.ALLOC_TRACES, ! AllocTraces_MinVal, iprof ); extract( actLst, null, IProf.ALLOC_OBJECT_METHOD_TRACES, ! AllocTraces_MinVal, iprof ); } ! if( withThreads ) { actLst.clear(); actLst2.clear(); --- 378,393 ---- extract( null, allocTypes, IProf.OBJECT_TYPES, IProf.NO_OPTIONAL_ARG, iprof ); ! extract( allocTypes, (conf.withTraces)? actLst : null, IProf.ALLOC_OBJECT_METHODS, IProf.NO_OPTIONAL_ARG, iprof ); ! if( conf.withTraces ) { //extract( methods, null, IProf.ALLOC_METHOD_TRACES, // AllocTraces_MinVal, iprof ); extract( null, null, IProf.ALLOC_TRACES, ! conf.AllocTraces_MinVal, iprof ); extract( actLst, null, IProf.ALLOC_OBJECT_METHOD_TRACES, ! conf.AllocTraces_MinVal, iprof ); } ! if( conf.withThreads ) { actLst.clear(); actLst2.clear(); *************** *** 396,414 **** extract( threads, actLst, IProf.ALLOC_THREAD_METHODS, IProf.NO_OPTIONAL_ARG, iprof ); ! if( withTraces ) { extract( actLst, null, IProf.ALLOC_THREAD_METHOD_TRACES, ! AllocTraces_MinVal, iprof ); } ! extract( actLst, (withTraces)? actLst2 : null, IProf.ALLOC_THREAD_METHOD_OBJECTS, IProf.NO_OPTIONAL_ARG, iprof ); ! if( withTraces ) { extract( actLst2, null, IProf.ALLOC_THREAD_OBJECT_METHOD_TRACES, ! AllocTraces_MinVal, iprof); } } } ! if( withMon ) { ! if( withTraces ) { //extract( methods, null, IProf.MON_METHOD_TRACES, // IProf.NO_OPTIONAL_ARG, iprof ); --- 397,415 ---- extract( threads, actLst, IProf.ALLOC_THREAD_METHODS, IProf.NO_OPTIONAL_ARG, iprof ); ! if( conf.withTraces ) { extract( actLst, null, IProf.ALLOC_THREAD_METHOD_TRACES, ! conf.AllocTraces_MinVal, iprof ); } ! extract( actLst, (conf.withTraces)? actLst2 : null, IProf.ALLOC_THREAD_METHOD_OBJECTS, IProf.NO_OPTIONAL_ARG, iprof ); ! if( conf.withTraces ) { extract( actLst2, null, IProf.ALLOC_THREAD_OBJECT_METHOD_TRACES, ! conf.AllocTraces_MinVal, iprof); } } } ! if( conf.withMon ) { ! if( conf.withTraces ) { //extract( methods, null, IProf.MON_METHOD_TRACES, // IProf.NO_OPTIONAL_ARG, iprof ); *************** *** 416,435 **** IProf.NO_OPTIONAL_ARG, iprof ); } ! if( withThreads ) { actLst.clear(); ! extract( threads, (withTraces) ? actLst : null, IProf.MON_THREAD_METHODS, IProf.NO_OPTIONAL_ARG, iprof ); ! if( withTraces ) { extract( actLst, null, IProf.MON_THREAD_METHOD_TRACES, ! MonTraces_MinVal, iprof ); } } } ! if ( withArenas ) { extract( null, arenas, IProf.ARENAS, IProf.NO_OPTIONAL_ARG, iprof ); } ! if ( withGC ) { extract( null, gcs, IProf.GCS, IProf.NO_OPTIONAL_ARG, iprof ); } --- 417,436 ---- IProf.NO_OPTIONAL_ARG, iprof ); } ! if( conf.withThreads ) { actLst.clear(); ! extract( threads, (conf.withTraces) ? actLst : null, IProf.MON_THREAD_METHODS, IProf.NO_OPTIONAL_ARG, iprof ); ! if( conf.withTraces ) { extract( actLst, null, IProf.MON_THREAD_METHOD_TRACES, ! conf.MonTraces_MinVal, iprof ); } } } ! if ( conf.withArenas ) { extract( null, arenas, IProf.ARENAS, IProf.NO_OPTIONAL_ARG, iprof ); } ! if ( conf.withGC ) { extract( null, gcs, IProf.GCS, IProf.NO_OPTIONAL_ARG, iprof ); } *************** *** 439,443 **** } catch( Exception e ) { ! System.out.println( "Just error\n" + e); } --- 440,444 ---- } catch( Exception e ) { ! System.out.println( "Just error\n" + e ); } *************** *** 1036,1039 **** --- 1037,1043 ---- /* * $Log$ + * Revision 1.13 2002/03/04 00:13:56 vachis + * configuration class added + * * Revision 1.12 2002/03/03 01:20:09 vachis * type of ID changed from int to Integer |