critical path: Clean up link list of content provider
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Fri, 13 May 2016 18:52:44 +0000 (14:52 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Tue, 5 Jul 2016 13:52:40 +0000 (09:52 -0400)
The link cache was not used because it was written to one map, but read
from another. So links were computed every time

Change-Id: Id3533034be15e1e974160338d9d5e56bda84992e
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/72761
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathView.java

index dd649a5f10eb80eed18899d69e4b3987a2a2834e..ce4cff904a61545c21764e9fa10412a1e551c096 100644 (file)
@@ -235,7 +235,6 @@ public class CriticalPathView extends AbstractTimeGraphView {
         private final Lock fSyncLock = new ReentrantLock();
         private final Map<Object, Map<Object, CriticalPathEntry>> workerMaps = new HashMap<>();
         private final Map<Object, List<TimeGraphEntry>> workerEntries = new HashMap<>();
-        private final Map<Object, List<ILinkEvent>> linkMap = new HashMap<>();
         private @Nullable Object fCurrentObject;
         private @Nullable BuildThread fBuildThread = null;
 
@@ -336,18 +335,19 @@ public class CriticalPathView extends AbstractTimeGraphView {
             if (current == null) {
                 return null;
             }
+            final ITmfTrace trace = getTrace();
+            if (trace == null) {
+                return null;
+            }
             /*
              * Critical path typically has relatively few links, so we calculate
              * and save them all, but just return those in range
              */
-            List<ILinkEvent> links = linkMap.get(current);
+            List<ILinkEvent> links = fLinks.get(trace, current);
             if (links != null) {
-                return links;
-            }
-            final ITmfTrace trace = getTrace();
-            if (trace == null) {
-                return null;
+                return getLinksInRange(links, startTime, endTime);
             }
+
             CriticalPathModule module = Iterables.<@Nullable CriticalPathModule> getFirst(
                     TmfTraceUtils.getAnalysisModulesOfClass(trace, CriticalPathModule.class), null);
             if (module == null) {
@@ -369,11 +369,14 @@ public class CriticalPathView extends AbstractTimeGraphView {
 
             /* find vertical links */
             graph.scanLineTraverse(vertex, new VerticalLinksVisitor(graph, graphLinks, entryMap));
-            fLinks.put(trace, checkNotNull(fCurrentObject), graphLinks);
-            links = graphLinks;
+            fLinks.put(trace, current, graphLinks);
+
+            return getLinksInRange(graphLinks, startTime, endTime);
+        }
 
+        private List<ILinkEvent> getLinksInRange(List<ILinkEvent> allLinks, long startTime, long endTime) {
             List<ILinkEvent> linksInRange = new ArrayList<>();
-            for (ILinkEvent link : links) {
+            for (ILinkEvent link : allLinks) {
                 if (((link.getTime() >= startTime) && (link.getTime() <= endTime)) ||
                         ((link.getTime() + link.getDuration() >= startTime) && (link.getTime() + link.getDuration() <= endTime))) {
                     linksInRange.add(link);
This page took 0.026844 seconds and 5 git commands to generate.