Update of /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/commun
In directory usw-pr-cvs1:/tmp/cvs-serv27735/net/sourceforge/javaprofiler/jpiimpl/commun
Modified Files:
IProf.java
Log Message:
calltree
Index: IProf.java
===================================================================
RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/commun/IProf.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** IProf.java 2001/12/09 16:50:42 1.9
--- IProf.java 2002/01/31 12:32:47 1.10
***************
*** 151,154 ****
--- 151,157 ----
private static final int F_RUN_GC = 11;
+ /// remote getCallTree() method identifier
+ private static final int F_GET_CALLTREE = 12;
+
/// internal I/O buffer
private Buffer _buf = new Buffer();
***************
*** 2038,2041 ****
--- 2041,2183 ----
return false;
}
+ }
+
+ /** One item of calltree. It contains all possible
+ ** data we can gain - cumulative time and pure time and
+ ** number of hits (how many times the method in given
+ ** position in the stack calltree was called).
+ ** Calltree shows us the order how methods were called. */
+
+ public class sCallTree {
+
+ /// time spent in the method (including sub-calls)
+ public long cumulativeTime;
+
+ /// number of calls of the method
+ public long hits;
+
+ /// time spent in the method (excluding sub-calls)
+ public long pureTime;
+
+ /// internal ID of method
+ public int methodInfoId;
+
+ /// internal ID of method
+ public int methodObjId;
+
+ /** methods called by this method
+ ** (list of sCallTree objects) */
+
+ public LinkedList children;
+
+ /// number of children
+ public int numOfChildren;
+ };
+
+ /** Get item of calltree from buffer. This method grabs one
+ ** item of calltree from binary buffer and transforms data
+ ** to sCallTree structure.
+ **
+ ** @param b binary buffer
+ ** @param offset offset where data start in the buffer
+ ** @param ct output structure
+ **
+ ** @return position of next item in the buffer */
+
+ private int getCallTreeItem( Buffer b, int offset, sCallTree ct) {
+
+ ct.cumulativeTime = b.getLong( offset);
+ offset += 8;
+
+ ct.hits = b.getLong( offset);
+ offset += 8;
+
+ ct.pureTime = b.getLong( offset);
+ offset += 8;
+
+ ct.methodInfoId = b.getInt( offset);
+ offset += 4;
+
+ ct.methodObjId = b.getInt( offset);
+ offset += 4;
+
+ ct.numOfChildren = b.getInt( offset);
+ offset += 4;
+
+ return offset;
+ }
+
+ /** Get subtree of calltree. This method recursively returns
+ ** the whole calltree - grabs it from binary buffer and stores
+ ** it as a tree of sCallTree structures.
+ **
+ ** @param b buffer with binary data
+ ** @param offset position of data in the buffer
+ ** @param ct output structure - root of the subtree
+ **
+ ** @return position of next item in the buffer */
+
+ private int getCallTree( Buffer b, int offset, sCallTree ct) {
+
+ offset = getCallTreeItem( b, offset, ct);
+
+ int num = ct.numOfChildren;
+
+ while( num > 0) {
+
+ sCallTree nct = new sCallTree();
+ offset = getCallTree( b, offset, nct);
+
+ if( ct.children == null) ct.children = new LinkedList();
+
+ ct.children.addLast( nct);
+ num--;
+ }
+
+ return offset;
+ }
+
+ /** Get calltree. This method returns the whole calltree
+ ** of methods for given thread.
+ **
+ ** @param threadObjId thread's object ID
+ **
+ ** @return == null (calltree is empty);
+ ** != null (a reference to the root of calltree) */
+
+ public synchronized sCallTree getCallTree( int threadObjId)
+
+ throws COMMUN_Exception,
+ BAD_OBJ_ID_Exception,
+ UNKNOWN_Exception {
+
+ _buf.clear();
+ _buf.putInt( F_GET_CALLTREE);
+ _buf.putInt( threadObjId);
+
+ _commun.write( _buf);
+ if( _commun.hasFailed()) throw new COMMUN_Exception();
+
+ _commun.read( _buf);
+ if( _commun.hasFailed()) throw new COMMUN_Exception();
+
+ int pos = 0;
+
+ int rc = _buf.getInt( pos);
+ pos += 4;
+
+ if( rc != RC_OK) {
+
+ if( rc == RC_BAD_OBJ_ID) throw new BAD_OBJ_ID_Exception();
+
+ throw new UNKNOWN_Exception();
+ }
+
+ if( _buf.getSize() == 4) return null;
+
+ sCallTree root = new sCallTree();
+ getCallTree( _buf, pos, root);
+
+ return root;
}
};
|