diff --git a/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java b/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java index fff5242..6f3a808 100644 --- a/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java +++ b/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java @@ -7,11 +7,14 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; import java.util.stream.Collectors; import org.ntlab.deltaExtractor.ExtractedStructure; import org.ntlab.trace.MethodExecution; import org.ntlab.trace.MethodInvocation; +import org.ntlab.trace.ObjectReference; import org.ntlab.trace.Reference; import org.ntlab.trace.Statement; import org.ntlab.trace.TracePoint; @@ -25,12 +28,14 @@ private Set references = new HashSet<>(); private List startPoints = new ArrayList<>(); // Common ancestor point private List relatedPoints = new ArrayList<>(); + private SortedSet timeStamps = new TreeSet<>(); // List of time stamps of related points public CollaborationObjectCallGraph(ExtractedStructure e) { references.addAll(e.getDelta().getSrcSide()); references.addAll(e.getDelta().getDstSide()); startPoints.add(e.getCoordinator()); relatedPoints.add(e.getRelatedTracePoint().duplicate()); + timeStamps.add(getTimeStampOfRelatedPoint(e.getRelatedTracePoint(), e)); } @Override @@ -53,6 +58,11 @@ return null; } + @Override + public SortedSet getTimeStamps() { + return timeStamps; + } + /** * Merge ExtractedStructure not to overlap reference. * @@ -117,10 +127,12 @@ startPoints.clear(); startPoints.add(lca); - // Is it in time stamp order? TracePoint otherRelatedTp = e.getRelatedTracePoint().duplicate(); - relatedPoints.add(otherRelatedTp); - relatedPoints = sortTracePointByTimeStamp(relatedPoints); + long rpTimeStamp = getTimeStampOfRelatedPoint(otherRelatedTp, e); + int idx = timeStamps.headSet(rpTimeStamp).size(); + relatedPoints.add(idx, otherRelatedTp); + timeStamps.add(rpTimeStamp); +// relatedPoints = sortTracePointByTimeStamp(relatedPoints); } /** @@ -147,6 +159,23 @@ } return qTmp; } + + private Long getTimeStampOfRelatedPoint(TracePoint relatedTracePoint, ExtractedStructure e) { + ObjectReference targetObj = null; + if (e.getDelta().getDstSide().size() > 0) { + targetObj = e.getDelta().getDstSide().get(0).getDstObject(); + } else { + targetObj = new ObjectReference(e.getCoordinator().getThisObjId(), e.getCoordinator().getThisClassName()); + } + if (relatedTracePoint.isMethodEntry() && relatedTracePoint.getMethodExecution().getArguments().contains(targetObj)) { + return relatedTracePoint.getMethodExecution().getEntryTime(); + } + if (relatedTracePoint.getStatement() instanceof MethodInvocation) { + return ((MethodInvocation) relatedTracePoint.getStatement()).getCalledMethodExecution().getExitTime(); + } else { + return relatedTracePoint.getStatement().getTimeStamp(); + } + } /** * Sort TracePoint in time stamp order.