|
From: Pavel V. <va...@us...> - 2002-09-08 14:38:32
|
Update of /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/data
In directory usw-pr-cvs1:/tmp/cvs-serv8754
Modified Files:
SnapshotImpl.java
Log Message:
fixies
now it returns somothing useful
probably some errors yet
Index: SnapshotImpl.java
===================================================================
RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/data/SnapshotImpl.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -r1.34 -r1.35
*** SnapshotImpl.java 7 Sep 2002 19:46:43 -0000 1.34
--- SnapshotImpl.java 8 Sep 2002 14:38:27 -0000 1.35
***************
*** 551,554 ****
--- 551,555 ----
long end = System.currentTimeMillis();
+ haveSnapshot = true;
//System.out.println( "\n\nTime: " + (end - start) );
}
***************
*** 1224,1231 ****
private void makeDiffSnapshot( Configuration conf, Snapshot a, Snapshot b )
{
- Map objMap = new HashMap(); //mapping objects from source (this) to
- // its copies in result
Object obj = null;
//problem with definition //FIXME
/* It's not clear what means difference on root objects, that
--- 1225,1232 ----
private void makeDiffSnapshot( Configuration conf, Snapshot a, Snapshot b )
{
Object obj = null;
+ if ( haveSnapshot )
+ throw new RuntimeException( "Can't create Snapshot, it already exists!");
//problem with definition //FIXME
/* It's not clear what means difference on root objects, that
***************
*** 1246,1250 ****
List[] result;
sourceLst1 = new ArrayList(1);
! sourceLst1.add(this);
sourceLst2 = new ArrayList(1);
sourceLst2.add(b);
--- 1247,1251 ----
List[] result;
sourceLst1 = new ArrayList(1);
! sourceLst1.add(a);
sourceLst2 = new ArrayList(1);
sourceLst2.add(b);
***************
*** 1255,1266 ****
//sideEffect creates appropriate MethodData instances
//this way was choosen because of effectvity
! result = AddDiffOfCildrenLists( sourceLst1, sourceLst2, "getMethods" );
if ( conf.withAllocTraces ) {
sourceLst1 = result[0];
sourceLst2 = result[1];
//sideEffect creates appropriate AllocTraceData instances
! result = AddDiffOfCildrenLists( sourceLst1, sourceLst2, "getTraces" );
}
}
}
--- 1256,1268 ----
//sideEffect creates appropriate MethodData instances
//this way was choosen because of effectvity
! result = AddDiffOfCildrenLists( sourceLst1, sourceLst2, "getAllocTypeMethods" );
if ( conf.withAllocTraces ) {
sourceLst1 = result[0];
sourceLst2 = result[1];
//sideEffect creates appropriate AllocTraceData instances
! result = AddDiffOfCildrenLists( sourceLst1, sourceLst2, "getAllocTypeTraces" );
}
}
+ haveSnapshot = true;
}
***************
*** 1334,1337 ****
--- 1336,1340 ----
{
boolean eqL = false;
+ boolean corespondingObjs = false;
AllocStat alloc1, alloc2;
***************
*** 1342,1358 ****
while( it1.hasNext() ) {
alloc1 = (AllocStat) it1.next();
! while ( it2.hasNext() ) {
! alloc2 = (AllocStat) it2.next();
!
eqL = false;
//test of equality
eqL = (alloc1.getLiveInstancesCount() == alloc2.getLiveInstancesCount());
! if ( eqL ) {
result[0].add( alloc1 );
result[1].add( alloc2 );
!
//creation
allocStatA = (AllocStatData) copyAndPutIn( alloc1 );
!
//difference
allocStatA.setAllocStat(
--- 1345,1364 ----
while( it1.hasNext() ) {
alloc1 = (AllocStat) it1.next();
! it2 = sourceLst2.listIterator();
! while ( it2.hasNext() ) {
! alloc2 = (AllocStat) it2.next();
!
! corespondingObjs = haveSameRoots( alloc1, alloc2 );
! if ( corespondingObjs ) {
eqL = false;
//test of equality
eqL = (alloc1.getLiveInstancesCount() == alloc2.getLiveInstancesCount());
! if ( !eqL ) {
result[0].add( alloc1 );
result[1].add( alloc2 );
!
//creation
allocStatA = (AllocStatData) copyAndPutIn( alloc1 );
!
//difference
allocStatA.setAllocStat(
***************
*** 1362,1367 ****
alloc1.getTotalInstancesSize() - alloc2.getTotalInstancesSize()
);
! }
}
}
}
--- 1368,1375 ----
alloc1.getTotalInstancesSize() - alloc2.getTotalInstancesSize()
);
! }
! break;
}
+ }
}
}
***************
*** 1386,1394 ****
ClassData class1 = (ClassData) type1.getComponentClass();
ClassData classA;
! if ( (obj = libIDs.get( class1.getID() )) == null ) {
! classA = (ClassData) copyAndPutIn( class1 );
}
else {
! classA = (ClassData) obj;
}
//------------creation
--- 1394,1407 ----
ClassData class1 = (ClassData) type1.getComponentClass();
ClassData classA;
! if ( class1 == null ) { //in cases like char[], ...
! classA = null;
}
else {
! if ( (obj = libIDs.get( class1.getID() )) == null ) {
! classA = (ClassData) copyAndPutIn( class1 );
! }
! else {
! classA = (ClassData) obj;
! }
}
//------------creation
***************
*** 1519,1522 ****
--- 1532,1584 ----
return result;
}
+
+ private boolean haveSameRoots( Object obj1, Object obj2 )
+ {
+ boolean sameType = true;
+ boolean sameLocation = true;
+ boolean sameThread = true;
+
+ if ( obj1.getClass() != obj2.getClass() ) {
+ return false;
+ }
+ if ( obj1 instanceof HasTypeRoot ) {
+ sameType = ((HasTypeRoot) obj1).getType().getName().equals(
+ ((HasTypeRoot) obj2).getType().getName()
+ );
+ }
+ if ( obj1 instanceof HasThreadRoot ) {
+ sameThread = ((HasThreadRoot) obj1).getThread().getName().equals(
+ ((HasThreadRoot) obj2).getThread().getName()
+ );
+ }
+ if ( obj1 instanceof HasLocationRoot ) {
+ LocationRef loc1 = ((HasLocationRoot) obj1).getLocation();
+ LocationRef loc2 = ((HasLocationRoot) obj2).getLocation();
+ sameLocation = loc1.getMethod().getName().equals(
+ loc2.getMethod().getName()
+ );
+ //HACK //FIXME
+ if ( loc1 instanceof TraceRef ) {
+ sameLocation = false;
+ FrameRef frm1, frm2;
+ List frames1 = ((TraceRef) loc1).getFrames();
+ List frames2 = ((TraceRef) loc2).getFrames();
+ if ( frames1.size() == frames2.size() ) {
+ for (int i = 0; i < frames1.size(); i++ ) {
+ frm1 = ((FrameRef) frames1.get(i));
+ frm2 = ((FrameRef) frames2.get(i));
+ sameLocation = (frm1.getLineNo() == frm2.getLineNo())
+ && (frm1.getMethod().getName().equals(
+ frm2.getMethod().getName()
+ )
+ );
+ if (!sameLocation)
+ break;
+ }
+ }
+ }
+ }
+ return sameType && sameLocation && sameThread;
+ }
}
***************
*** 1532,1535 ****
--- 1594,1603 ----
/*
* $Log$
+ * Revision 1.35 2002/09/08 14:38:27 vachis
+ * fixies
+ * now it returns somothing useful
+ *
+ * probably some errors yet
+ *
* Revision 1.34 2002/09/07 19:46:43 vachis
* implementation of difference snapshot
|