critical path: bug 490086 Set start/end time for the trace
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Fri, 20 May 2016 20:10:09 +0000 (16:10 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Tue, 31 May 2016 14:25:07 +0000 (10:25 -0400)
Previously, the start and end times of the critical path were set when building
the entries list for each critical path. Each worker had different start/end
times, different from the trace's and when getting a previously calculated
critical path, it would not reset the start/end time so the results were not
displayed correctly.

This patch sets the start and end time of the critical path view with the data
from the main execution graph, not the current worker's critical path.

It also gets the previously computed statistics in the content provider instead
of the analysis start.

Change-Id: I7c08f7776b375b033575bc56c51d1cff36b72068
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/73513
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Hudson CI
analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java

index 1fab74e3e32850f1301989bdbede2e776dbd98b7..db2e960313ba00bb44ce28a4658043313f8f4f1d 100644 (file)
@@ -30,6 +30,7 @@ import org.eclipse.tracecompass.analysis.graph.core.base.TmfEdge;
 import org.eclipse.tracecompass.analysis.graph.core.base.TmfEdge.EdgeType;
 import org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph;
 import org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex;
+import org.eclipse.tracecompass.analysis.graph.core.building.TmfGraphBuilderModule;
 import org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule;
 import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.internal.analysis.graph.core.base.TmfGraphStatistics;
@@ -145,12 +146,6 @@ public class CriticalPathView extends AbstractTimeGraphView {
                 fRootList.put(owner, entry);
             }
 
-            @Override
-            public void visit(TmfVertex node) {
-                setStartTime(Math.min(getStartTime(), node.getTs()));
-                setEndTime(Math.max(getEndTime(), node.getTs()));
-            }
-
             @Override
             public void visit(TmfEdge link, boolean horizontal) {
                 if (horizontal) {
@@ -219,6 +214,9 @@ public class CriticalPathView extends AbstractTimeGraphView {
                     }
                     module.schedule();
                     if (module.waitForCompletion(fMonitor)) {
+                        // Module is completed, set the start and end time of
+                        // this view
+                        setStartEndTime(module);
                         refresh();
                     }
 
@@ -260,9 +258,17 @@ public class CriticalPathView extends AbstractTimeGraphView {
         private ITimeGraphEntry[] getWorkerEntries(IGraphWorker worker) {
             fCurrentObject = worker;
             List<TimeGraphEntry> entries = workerEntries.get(worker);
+            ITmfTrace trace = getTrace();
             if (entries == null) {
                 buildEntryList(worker);
                 entries = workerEntries.get(worker);
+            } else if (trace != null) {
+                // Get the statistics object for this worker
+                TmfGraphStatistics stats = fObjectStatistics.get(trace, worker);
+                if (stats == null) {
+                    stats = new TmfGraphStatistics();
+                }
+                fStats = stats;
             }
 
             return (entries == null) ?
@@ -279,8 +285,6 @@ public class CriticalPathView extends AbstractTimeGraphView {
             if (graph == null) {
                 return;
             }
-            setStartTime(Long.MAX_VALUE);
-            setEndTime(Long.MIN_VALUE);
 
             final HashMap<Object, CriticalPathEntry> rootList = new HashMap<>();
             fLinks.remove(trace, worker);
@@ -587,12 +591,6 @@ public class CriticalPathView extends AbstractTimeGraphView {
             throw new IllegalStateException("Trace is null"); //$NON-NLS-1$
         }
         IGraphWorker worker = (IGraphWorker) obj;
-        TmfGraphStatistics stats = fObjectStatistics.get(trace, worker);
-        if (stats == null) {
-            stats = new TmfGraphStatistics();
-            fObjectStatistics.put(trace, worker, stats);
-        }
-        fStats = stats;
 
         TimeGraphEntry tge = new CriticalPathBaseEntry(worker);
         List<TimeGraphEntry> list = Collections.singletonList(tge);
@@ -600,4 +598,36 @@ public class CriticalPathView extends AbstractTimeGraphView {
         refresh();
     }
 
+    private void setStartEndTime(CriticalPathModule module) {
+        // Initialize the start/end time of the view to trace's times
+        ITmfTrace trace = getTrace();
+        if (trace == null) {
+            throw new IllegalStateException("The trace should not be null when we have a critical path to display"); //$NON-NLS-1$
+        }
+        long start = trace.getStartTime().toNanos();
+        long end = trace.getEndTime().toNanos();
+
+        // Set the start/end time of the view
+        Object paramGraph = module.getParameter(CriticalPathModule.PARAM_GRAPH);
+        if (paramGraph instanceof TmfGraphBuilderModule) {
+            TmfGraphBuilderModule graphModule = (TmfGraphBuilderModule) paramGraph;
+            TmfGraph graph = graphModule.getGraph();
+            if (graph == null) {
+                return;
+            }
+            TmfVertex head = graph.getHead();
+            if (head != null) {
+                start = Math.min(start, head.getTs());
+                for (IGraphWorker w : graph.getWorkers()) {
+                    TmfVertex tail = graph.getTail(w);
+                    if (tail != null) {
+                        end = Math.max(end, tail.getTs());
+                    }
+                }
+            }
+        }
+        setStartTime(start);
+        setEndTime(end);
+    }
+
 }
index abb3bca922fb526e064a86ddb6a33354d274b39c..3c6619064b0ba10dbc6897026b5271748e3d9be3 100644 (file)
@@ -1477,8 +1477,8 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
         if (signal.getTrace() == fTrace) {
             fTrace = null;
             fEditorFile = null;
-            fStartTime = SWT.DEFAULT;
-            fEndTime = SWT.DEFAULT;
+            setStartTime(SWT.DEFAULT);
+            setEndTime(SWT.DEFAULT);
             refresh();
         }
     }
@@ -1573,8 +1573,8 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
             if (fEntryList == null) {
                 rebuild();
             } else {
-                fStartTime = fTrace.getStartTime().toNanos();
-                fEndTime = fTrace.getEndTime().toNanos();
+                setStartTime(fTrace.getStartTime().toNanos());
+                setEndTime(fTrace.getEndTime().toNanos());
                 refresh();
             }
         }
This page took 0.027115 seconds and 5 git commands to generate.