tmf : Add latency statistics view for the pattern analysis
authorJean-Christian Kouame <jean-christian.kouame@ericsson.com>
Wed, 23 Mar 2016 15:29:32 +0000 (11:29 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Tue, 5 Apr 2016 20:08:52 +0000 (16:08 -0400)
Change-Id: Ie4fe7e7e68e8e3b074ddb5f0b3ec97a554652166
Signed-off-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/67842
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
31 files changed:
analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/latency/statistics/SystemCallLatencyStatisticsAnalysisModule.java
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/SystemCallLatencyStatisticsView.java
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/SystemCallLatencyStatisticsViewer.java
analysis/org.eclipse.tracecompass.analysis.timing.core.tests/src/org/eclipse/tracecompass/analysis/timing/core/tests/segmentstore/statistics/SegmentStoreStatisticsTest.java
analysis/org.eclipse.tracecompass.analysis.timing.core/META-INF/MANIFEST.MF
analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/statistics/AbstractSegmentStatisticsAnalysis.java [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/statistics/SegmentStoreStatistics.java [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/statistics/package-info.java [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/segmentstore/statistics/AbstractSegmentStatisticsAnalysis.java [deleted file]
analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/segmentstore/statistics/SegmentStoreStatistics.java [deleted file]
analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/segmentstore/statistics/package-info.java [deleted file]
analysis/org.eclipse.tracecompass.analysis.timing.ui/META-INF/MANIFEST.MF
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/statistics/AbstractSegmentStoreStatisticsView.java [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/statistics/AbstractSegmentStoreStatisticsViewer.java [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/statistics/Messages.java [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/statistics/messages.properties [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/statistics/package-info.java [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/statistics/AbstractSegmentStoreStatisticsView.java [deleted file]
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/statistics/AbstractSegmentStoreStatisticsViewer.java [deleted file]
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/statistics/Messages.java [deleted file]
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/statistics/messages.properties [deleted file]
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/statistics/package-info.java [deleted file]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/pattern/stateprovider/XmlPatternLatencyStatisticsAnalysis.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/icons/eview16/statistics_view.gif [new file with mode: 0755]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/plugin.properties
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/plugin.xml
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/module/Messages.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/module/messages.properties
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternStatisticsView.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternStatisticsViewer.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/module/TmfXmlAnalysisOutputSource.java

index 7408a5865a57dd2f3b8644acfaa110099481b87a..46da158bbedbd7564d2cb42c274aef6c90605919 100644 (file)
@@ -16,7 +16,7 @@ import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.analysis.os.linux.core.latency.SystemCall;
 import org.eclipse.tracecompass.analysis.os.linux.core.latency.SystemCallLatencyAnalysis;
 import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider;
-import org.eclipse.tracecompass.internal.analysis.timing.core.segmentstore.statistics.AbstractSegmentStatisticsAnalysis;
+import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.AbstractSegmentStatisticsAnalysis;
 import org.eclipse.tracecompass.segmentstore.core.ISegment;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
index daf9f9e3d05e53c8c850cd52a0f54d72adb6c75c..509809edb88c6662d050bed36369520904444b26 100644 (file)
@@ -12,8 +12,8 @@
 package org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency.statistics;
 
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.statistics.AbstractSegmentStoreStatisticsView;
-import org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.statistics.AbstractSegmentStoreStatisticsViewer;
+import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.statistics.AbstractSegmentStoreStatisticsView;
+import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.statistics.AbstractSegmentStoreStatisticsViewer;
 
 /**
  * View to display latency statistics.
index 013b5c5fbdce00ea66200acbbe6af2586c6d82c0..49e8b376ffc437bde3bbb5de888d4e7b9b58e00f 100644 (file)
@@ -19,9 +19,9 @@ import java.util.Map.Entry;
 
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.SegmentStoreStatistics;
+import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.statistics.AbstractSegmentStoreStatisticsViewer;
 import org.eclipse.tracecompass.internal.analysis.os.linux.core.latency.statistics.SystemCallLatencyStatisticsAnalysisModule;
-import org.eclipse.tracecompass.internal.analysis.timing.core.segmentstore.statistics.SegmentStoreStatistics;
-import org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.statistics.AbstractSegmentStoreStatisticsViewer;
 import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule;
 import org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry;
 import org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeViewerEntry;
index 67338a319d1b56a4d360abf08195c9bbe98d5b3b..2bda6263ac49c936a26ee818fc183f692f33f7e7 100644 (file)
@@ -19,7 +19,7 @@ import java.util.Random;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.analysis.os.linux.core.latency.SystemCall;
 import org.eclipse.tracecompass.analysis.os.linux.core.latency.SystemCall.InitialInfo;
-import org.eclipse.tracecompass.internal.analysis.timing.core.segmentstore.statistics.SegmentStoreStatistics;
+import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.SegmentStoreStatistics;
 import org.eclipse.tracecompass.segmentstore.core.ISegment;
 import org.junit.Test;
 
index 0938c3bfaf9632ea1abc70d1f99be3dd80e711c0..97d6201df7c0945aa1bb0ddc3126ef0b7964c58a 100644 (file)
@@ -15,11 +15,7 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.tracecompass.tmf.core,
  org.eclipse.tracecompass.segmentstore.core
 Export-Package: org.eclipse.tracecompass.analysis.timing.core.segmentstore,
- org.eclipse.tracecompass.internal.analysis.timing.core,
- org.eclipse.tracecompass.internal.analysis.timing.core.segmentstore.statistics;
-  x-friends:="org.eclipse.tracecompass.analysis.os.linux.ui,
-   org.eclipse.tracecompass.analysis.timing.ui,
-   org.eclipse.tracecompass.analysis.timing.core.tests,
-   org.eclipse.tracecompass.analysis.os.linux.core"
+ org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics,
+ org.eclipse.tracecompass.internal.analysis.timing.core
 Import-Package: com.google.common.collect,
  com.google.common.hash
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/statistics/AbstractSegmentStatisticsAnalysis.java b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/statistics/AbstractSegmentStatisticsAnalysis.java
new file mode 100644 (file)
index 0000000..efbd8b4
--- /dev/null
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics;
+
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider;
+import org.eclipse.tracecompass.segmentstore.core.ISegment;
+import org.eclipse.tracecompass.segmentstore.core.ISegmentStore;
+import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
+import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Abstract analysis to build statistics data for a segment store
+ *
+ * @author Jean-Christian Kouame
+ */
+public abstract class AbstractSegmentStatisticsAnalysis extends TmfAbstractAnalysisModule {
+
+    private @Nullable IAnalysisModule fSegmentStoreProviderModule;
+
+    private @Nullable SegmentStoreStatistics fTotalStats;
+
+    private @Nullable Map<String, SegmentStoreStatistics> fPerSegmentTypeStats;
+
+    @Override
+    protected Iterable<IAnalysisModule> getDependentAnalyses() {
+        ITmfTrace trace = getTrace();
+        if (trace != null) {
+            ISegmentStoreProvider provider = getSegmentProviderAnalysis(trace);
+            if (provider instanceof IAnalysisModule) {
+                fSegmentStoreProviderModule = (IAnalysisModule) provider;
+                return ImmutableList.of((IAnalysisModule) provider);
+            }
+        }
+        return super.getDependentAnalyses();
+    }
+
+    @Override
+    protected boolean executeAnalysis(IProgressMonitor monitor) throws TmfAnalysisException {
+        IAnalysisModule segmentStoreProviderModule = fSegmentStoreProviderModule;
+        ITmfTrace trace = getTrace();
+        if (!(segmentStoreProviderModule instanceof ISegmentStoreProvider) || (trace == null)) {
+            return false;
+        }
+        segmentStoreProviderModule.waitForCompletion();
+
+        ISegmentStore<ISegment> segStore = ((ISegmentStoreProvider) segmentStoreProviderModule).getSegmentStore();
+
+        if (segStore != null) {
+
+            boolean result = calculateTotalManual(segStore, monitor);
+
+            if (!result) {
+                return false;
+            }
+
+            result = calculateTotalPerType(segStore, monitor);
+            if (!result) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private boolean calculateTotalManual(ISegmentStore<ISegment> store, IProgressMonitor monitor) {
+        SegmentStoreStatistics total = new SegmentStoreStatistics();
+        Iterator<ISegment> iter = store.iterator();
+        while (iter.hasNext()) {
+            if (monitor.isCanceled()) {
+                return false;
+            }
+            ISegment segment = iter.next();
+            total.update(checkNotNull(segment));
+        }
+        fTotalStats = total;
+        return true;
+    }
+
+    private boolean calculateTotalPerType(ISegmentStore<ISegment> store, IProgressMonitor monitor) {
+        Map<String, SegmentStoreStatistics> perSegmentTypeStats = new HashMap<>();
+
+        Iterator<ISegment> iter = store.iterator();
+        while (iter.hasNext()) {
+            if (monitor.isCanceled()) {
+                return false;
+            }
+            ISegment segment = iter.next();
+            String segmentType = getSegmentType(segment);
+            if (segmentType != null) {
+                SegmentStoreStatistics values = perSegmentTypeStats.get(segmentType);
+                if (values == null) {
+                    values = new SegmentStoreStatistics();
+                }
+                values.update(segment);
+                perSegmentTypeStats.put(segmentType, values);
+            }
+        }
+        fPerSegmentTypeStats = perSegmentTypeStats;
+        return true;
+    }
+
+    /**
+     * Get the type of a segment. Statistics per type will use this type as a
+     * key
+     *
+     * @param segment
+     *            the segment for which to get the type
+     * @return The type of the segment
+     */
+    protected abstract @Nullable String getSegmentType(ISegment segment);
+
+    /**
+     * Find the segment store provider used for this analysis
+     *
+     * @param trace
+     *            The active trace
+     *
+     * @return The segment store provider
+     */
+    protected abstract @Nullable ISegmentStoreProvider getSegmentProviderAnalysis(ITmfTrace trace);
+
+    @Override
+    protected void canceling() {
+    }
+
+    /**
+     * The total statistics
+     *
+     * @return the total statistics
+     */
+    public @Nullable SegmentStoreStatistics getTotalStats() {
+        return fTotalStats;
+    }
+
+    /**
+     * The per syscall statistics
+     *
+     * @return the per syscall statistics
+     */
+    public @Nullable Map<String, SegmentStoreStatistics> getPerSegmentTypeStats() {
+        return fPerSegmentTypeStats;
+    }
+
+}
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/statistics/SegmentStoreStatistics.java b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/statistics/SegmentStoreStatistics.java
new file mode 100644 (file)
index 0000000..d1f4a1d
--- /dev/null
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Bernd Hufmann - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics;
+
+import org.eclipse.tracecompass.segmentstore.core.ISegment;
+
+/**
+ * Class to calculate simple segment store statistics (min, max, average)
+ *
+ * @author Bernd Hufmann
+ */
+public class SegmentStoreStatistics {
+    private long fMin;
+    private long fMax;
+    private long fNbSegments;
+    private double fAverage;
+    private double fVariance;
+
+    /**
+     * Constructor
+     */
+    public SegmentStoreStatistics() {
+        fMin = Long.MAX_VALUE;
+        fMax = Long.MIN_VALUE;
+        fNbSegments = 0;
+        fAverage = 0.0;
+        fVariance = 0.0;
+    }
+
+    /**
+     * Get minimum value
+     *
+     * @return minimum value
+     */
+    public long getMin() {
+        return fMin;
+    }
+
+    /**
+     * Get maximum value
+     *
+     * @return maximum value
+     */
+    public long getMax() {
+        return fMax;
+    }
+
+    /**
+     * Get number of segments analyzed
+     *
+     * @return number of segments analyzed
+     */
+    public long getNbSegments() {
+        return fNbSegments;
+    }
+
+    /**
+     * Gets the arithmetic average
+     *
+     * @return arithmetic average
+     */
+    public double getAverage() {
+        return fAverage;
+    }
+
+    /**
+     * Gets the standard deviation of the segments, uses the online algorithm
+     * shown here <a href=
+     * "https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Online_algorithm">
+     * Wikipedia article of dec 3 2015 </a>
+     *
+     * @return the standard deviation of the segment store, will return NaN if
+     *         there are less than 3 elements
+     */
+    public double getStdDev() {
+        return fNbSegments > 2 ? Math.sqrt(fVariance / (fNbSegments - 1)) : Double.NaN;
+    }
+
+    /**
+     * Update the statistics based on a given segment
+     * <p>
+     * This is an online algorithm and must retain a complexity of O(1)
+     *
+     * @param segment
+     *            the segment used for the update
+     */
+    public void update(ISegment segment) {
+        long value = segment.getLength();
+        /*
+         * Min and max are trivial, as well as number of segments
+         */
+        fMin = Math.min(fMin, value);
+        fMax = Math.max(fMax, value);
+
+        fNbSegments++;
+        /*
+         * The running mean is not trivial, see proof in javadoc.
+         */
+        double delta = value - fAverage;
+        fAverage += delta / fNbSegments;
+        fVariance += delta * (value - fAverage);
+    }
+}
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/statistics/package-info.java b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/statistics/package-info.java
new file mode 100644 (file)
index 0000000..2bb909d
--- /dev/null
@@ -0,0 +1,11 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+@org.eclipse.jdt.annotation.NonNullByDefault
+package org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics;
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/segmentstore/statistics/AbstractSegmentStatisticsAnalysis.java b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/segmentstore/statistics/AbstractSegmentStatisticsAnalysis.java
deleted file mode 100644 (file)
index 7a79a34..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.tracecompass.internal.analysis.timing.core.segmentstore.statistics;
-
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider;
-import org.eclipse.tracecompass.segmentstore.core.ISegment;
-import org.eclipse.tracecompass.segmentstore.core.ISegmentStore;
-import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
-import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule;
-import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
-import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Abstract analysis to build statistics data for a segment store
- *
- * @author Jean-Christian Kouame
- */
-public abstract class AbstractSegmentStatisticsAnalysis extends TmfAbstractAnalysisModule {
-
-    private @Nullable IAnalysisModule fSegmentStoreProviderModule;
-
-    private @Nullable SegmentStoreStatistics fTotalStats;
-
-    private @Nullable Map<String, SegmentStoreStatistics> fPerSegmentTypeStats;
-
-    @Override
-    protected Iterable<IAnalysisModule> getDependentAnalyses() {
-        ITmfTrace trace = getTrace();
-        if (trace != null) {
-            ISegmentStoreProvider provider = getSegmentProviderAnalysis(trace);
-            if (provider instanceof IAnalysisModule) {
-                fSegmentStoreProviderModule = (IAnalysisModule) provider;
-                return ImmutableList.of((IAnalysisModule) provider);
-            }
-        }
-        return super.getDependentAnalyses();
-    }
-
-    @Override
-    protected boolean executeAnalysis(IProgressMonitor monitor) throws TmfAnalysisException {
-        IAnalysisModule segmentStoreProviderModule = fSegmentStoreProviderModule;
-        ITmfTrace trace = getTrace();
-        if (!(segmentStoreProviderModule instanceof ISegmentStoreProvider) || (trace == null)) {
-            return false;
-        }
-        segmentStoreProviderModule.waitForCompletion();
-
-        ISegmentStore<ISegment> segStore = ((ISegmentStoreProvider) segmentStoreProviderModule).getSegmentStore();
-
-        if (segStore != null) {
-
-            boolean result = calculateTotalManual(segStore, monitor);
-
-            if (!result) {
-                return false;
-            }
-
-            result = calculateTotalPerType(segStore, monitor);
-            if (!result) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    private boolean calculateTotalManual(ISegmentStore<ISegment> store, IProgressMonitor monitor) {
-        SegmentStoreStatistics total = new SegmentStoreStatistics();
-        Iterator<ISegment> iter = store.iterator();
-        while (iter.hasNext()) {
-            if (monitor.isCanceled()) {
-                return false;
-            }
-            ISegment segment = iter.next();
-            total.update(checkNotNull(segment));
-        }
-        fTotalStats = total;
-        return true;
-    }
-
-    private boolean calculateTotalPerType(ISegmentStore<ISegment> store, IProgressMonitor monitor) {
-        Map<String, SegmentStoreStatistics> perSegmentTypeStats = new HashMap<>();
-
-        Iterator<ISegment> iter = store.iterator();
-        while (iter.hasNext()) {
-            if (monitor.isCanceled()) {
-                return false;
-            }
-            ISegment segment = iter.next();
-            String segmentType = getSegmentType(segment);
-            if (segmentType != null) {
-                SegmentStoreStatistics values = perSegmentTypeStats.get(segmentType);
-                if (values == null) {
-                    values = new SegmentStoreStatistics();
-                }
-                values.update(segment);
-                perSegmentTypeStats.put(segmentType, values);
-            }
-        }
-        fPerSegmentTypeStats = perSegmentTypeStats;
-        return true;
-    }
-
-    /**
-     * Get the type of a segment. Statistics per type will use this type as a
-     * key
-     *
-     * @param segment
-     *            the segment for which to get the type
-     * @return The type of the segment
-     */
-    protected abstract @Nullable String getSegmentType(ISegment segment);
-
-    /**
-     * Find the segment store provider used for this analysis
-     *
-     * @param trace
-     *            The active trace
-     *
-     * @return The segment store provider
-     */
-    protected abstract @Nullable ISegmentStoreProvider getSegmentProviderAnalysis(ITmfTrace trace);
-
-    @Override
-    protected void canceling() {
-    }
-
-    /**
-     * The total statistics
-     *
-     * @return the total statistics
-     */
-    public @Nullable SegmentStoreStatistics getTotalStats() {
-        return fTotalStats;
-    }
-
-    /**
-     * The per syscall statistics
-     *
-     * @return the per syscall statistics
-     */
-    public @Nullable Map<String, SegmentStoreStatistics> getPerSegmentTypeStats() {
-        return fPerSegmentTypeStats;
-    }
-
-}
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/segmentstore/statistics/SegmentStoreStatistics.java b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/segmentstore/statistics/SegmentStoreStatistics.java
deleted file mode 100644 (file)
index 892c404..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015, 2016 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.tracecompass.internal.analysis.timing.core.segmentstore.statistics;
-
-import org.eclipse.tracecompass.segmentstore.core.ISegment;
-
-/**
- * Class to calculate simple segment store statistics (min, max, average)
- *
- * @author Bernd Hufmann
- */
-public class SegmentStoreStatistics {
-    private long fMin;
-    private long fMax;
-    private long fNbSegments;
-    private double fAverage;
-    private double fVariance;
-
-    /**
-     * Constructor
-     */
-    public SegmentStoreStatistics() {
-        fMin = Long.MAX_VALUE;
-        fMax = Long.MIN_VALUE;
-        fNbSegments = 0;
-        fAverage = 0.0;
-        fVariance = 0.0;
-    }
-
-    /**
-     * Get minimum value
-     *
-     * @return minimum value
-     */
-    public long getMin() {
-        return fMin;
-    }
-
-    /**
-     * Get maximum value
-     *
-     * @return maximum value
-     */
-    public long getMax() {
-        return fMax;
-    }
-
-    /**
-     * Get number of segments analyzed
-     *
-     * @return number of segments analyzed
-     */
-    public long getNbSegments() {
-        return fNbSegments;
-    }
-
-    /**
-     * Gets the arithmetic average
-     *
-     * @return arithmetic average
-     */
-    public double getAverage() {
-        return fAverage;
-    }
-
-    /**
-     * Gets the standard deviation of the segments, uses the online algorithm
-     * shown here <a href=
-     * "https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Online_algorithm">
-     * Wikipedia article of dec 3 2015 </a>
-     *
-     * @return the standard deviation of the segment store, will return NaN if
-     *         there are less than 3 elements
-     */
-    public double getStdDev() {
-        return fNbSegments > 2 ? Math.sqrt(fVariance / (fNbSegments - 1)) : Double.NaN;
-    }
-
-    /**
-     * Update the statistics based on a given segment
-     * <p>
-     * This is an online algorithm and must retain a complexity of O(1)
-     *
-     * @param segment
-     *            the segment used for the update
-     */
-    public void update(ISegment segment) {
-        long value = segment.getLength();
-        /*
-         * Min and max are trivial, as well as number of segments
-         */
-        fMin = Math.min(fMin, value);
-        fMax = Math.max(fMax, value);
-
-        fNbSegments++;
-        /*
-         * The running mean is not trivial, see proof in javadoc.
-         */
-        double delta = value - fAverage;
-        fAverage += delta / fNbSegments;
-        fVariance += delta * (value - fAverage);
-    }
-}
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/segmentstore/statistics/package-info.java b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/internal/analysis/timing/core/segmentstore/statistics/package-info.java
deleted file mode 100644 (file)
index 8eccbb8..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015, 2016 Ericsson
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-
-@org.eclipse.jdt.annotation.NonNullByDefault
-package org.eclipse.tracecompass.internal.analysis.timing.core.segmentstore.statistics;
index 1e09c3b392ac24cc0acc220e5983a81a094cc855..8a8e5d3483bfb46b3d2e37fcb06f750ae67edac1 100644 (file)
@@ -20,9 +20,9 @@ Require-Bundle: org.eclipse.ui,
 Export-Package: org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore,
  org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.density,
  org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.scatter,
+ org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.statistics,
  org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.table,
  org.eclipse.tracecompass.internal.analysis.timing.ui,
  org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.density,
  org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.scatter,
- org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.statistics;x-friends:="org.eclipse.tracecompass.analysis.os.linux.ui",
  org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.table
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/statistics/AbstractSegmentStoreStatisticsView.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/statistics/AbstractSegmentStoreStatisticsView.java
new file mode 100644 (file)
index 0000000..069c674
--- /dev/null
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Bernd Hufmann - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.statistics;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
+import org.eclipse.tracecompass.tmf.ui.views.TmfView;
+
+/**
+ * Abstract view to to be extended to display segment store statistics.
+ *
+ * @author Bernd Hufmann
+ *
+ */
+public abstract class AbstractSegmentStoreStatisticsView extends TmfView {
+
+    @Nullable private AbstractSegmentStoreStatisticsViewer fStatsViewer = null;
+
+    /**
+     * Constructor
+     */
+    public AbstractSegmentStoreStatisticsView() {
+        super("StatisticsView"); //$NON-NLS-1$
+    }
+
+    @Override
+    public void createPartControl(@Nullable Composite parent) {
+        super.createPartControl(parent);
+        AbstractSegmentStoreStatisticsViewer statsViewer = createSegmentStoreStatisticsViewer(NonNullUtils.checkNotNull(parent));
+        ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
+        if (trace != null) {
+            statsViewer.loadTrace(trace);
+        }
+        fStatsViewer = statsViewer;
+    }
+
+    @Override
+    public void setFocus() {
+        AbstractSegmentStoreStatisticsViewer statsViewer = fStatsViewer;
+        if (statsViewer != null) {
+            statsViewer.getControl().setFocus();
+        }
+    }
+
+    @Override
+    public void dispose() {
+        super.dispose();
+        AbstractSegmentStoreStatisticsViewer statsViewer = fStatsViewer;
+        if (statsViewer != null) {
+            statsViewer.dispose();
+        }
+    }
+
+    /**
+     * Creates a segment store statistics viewer instance.
+     *
+     * @param parent
+     *            the parent composite to create the viewer in.
+     * @return the latency statistics viewer implementation
+     */
+    protected abstract AbstractSegmentStoreStatisticsViewer createSegmentStoreStatisticsViewer(Composite parent);
+
+}
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/statistics/AbstractSegmentStoreStatisticsViewer.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/statistics/AbstractSegmentStoreStatisticsViewer.java
new file mode 100644 (file)
index 0000000..30cfda3
--- /dev/null
@@ -0,0 +1,298 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Bernd Hufmann - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.statistics;
+
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
+import java.text.Format;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.SegmentStoreStatistics;
+import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.SubSecondTimeWithUnitFormat;
+import org.eclipse.tracecompass.internal.analysis.timing.ui.Activator;
+import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.tracecompass.tmf.ui.viewers.tree.AbstractTmfTreeViewer;
+import org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeColumnDataProvider;
+import org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeColumnData;
+import org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeViewerEntry;
+
+/**
+ * An abstract tree viewer implementation for displaying segment store
+ * statistics
+ *
+ * @author Bernd Hufmann
+ *
+ */
+public abstract class AbstractSegmentStoreStatisticsViewer extends AbstractTmfTreeViewer {
+
+    private static final Format FORMATTER = new SubSecondTimeWithUnitFormat();
+
+    @Nullable
+    private TmfAbstractAnalysisModule fModule;
+
+    private static final String[] COLUMN_NAMES = new String[] {
+            checkNotNull(Messages.SegmentStoreStatistics_LevelLabel),
+            checkNotNull(Messages.SegmentStoreStatistics_Statistics_MinLabel),
+            checkNotNull(Messages.SegmentStoreStatistics_MaxLabel),
+            checkNotNull(Messages.SegmentStoreStatistics_AverageLabel),
+            checkNotNull(Messages.SegmentStoreStatisticsViewer_StandardDeviation)
+    };
+
+    /**
+     * Constructor
+     *
+     * @param parent
+     *            the parent composite
+     */
+    public AbstractSegmentStoreStatisticsViewer(Composite parent) {
+        super(parent, false);
+        setLabelProvider(new SegmentStoreStatisticsLabelProvider());
+    }
+
+    /** Provides label for the Segment Store tree viewer cells */
+    protected static class SegmentStoreStatisticsLabelProvider extends TreeLabelProvider {
+
+        @Override
+        public String getColumnText(@Nullable Object element, int columnIndex) {
+            String value = ""; //$NON-NLS-1$
+            if (element instanceof HiddenTreeViewerEntry) {
+                if (columnIndex == 0) {
+                    value = ((HiddenTreeViewerEntry) element).getName();
+                }
+            } else if (element instanceof SegmentStoreStatisticsEntry) {
+                SegmentStoreStatisticsEntry entry = (SegmentStoreStatisticsEntry) element;
+                if (columnIndex == 0) {
+                    return String.valueOf(entry.getName());
+                }
+                if (entry.getEntry().getNbSegments() > 0) {
+                    if (columnIndex == 1) {
+                        value = toFormattedString(entry.getEntry().getMin());
+                    } else if (columnIndex == 2) {
+                        value = String.valueOf(toFormattedString(entry.getEntry().getMax()));
+                    } else if (columnIndex == 3) {
+                        value = String.valueOf(toFormattedString(entry.getEntry().getAverage()));
+                    } else if (columnIndex == 4) {
+                        value = String.valueOf(toFormattedString(entry.getEntry().getStdDev()));
+                    }
+                }
+            }
+            return checkNotNull(value);
+        }
+    }
+
+    /**
+     * Creates the statistics analysis module
+     *
+     * @return the statistics analysis module
+     */
+    @Nullable
+    protected abstract TmfAbstractAnalysisModule createStatisticsAnalysiModule();
+
+    /**
+     * Gets the statistics analysis module
+     *
+     * @return the statistics analysis module
+     */
+    @Nullable
+    public TmfAbstractAnalysisModule getStatisticsAnalysisModule() {
+        return fModule;
+    }
+
+    @Override
+    protected ITmfTreeColumnDataProvider getColumnDataProvider() {
+        return new ITmfTreeColumnDataProvider() {
+
+            @Override
+            public List<@Nullable TmfTreeColumnData> getColumnData() {
+                /* All columns are sortable */
+                List<@Nullable TmfTreeColumnData> columns = new ArrayList<>();
+                TmfTreeColumnData column = new TmfTreeColumnData(COLUMN_NAMES[0]);
+                column.setAlignment(SWT.RIGHT);
+                column.setComparator(new ViewerComparator() {
+                    @Override
+                    public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
+                        if ((e1 == null) || (e2 == null)) {
+                            return 0;
+                        }
+
+                        SegmentStoreStatisticsEntry n1 = (SegmentStoreStatisticsEntry) e1;
+                        SegmentStoreStatisticsEntry n2 = (SegmentStoreStatisticsEntry) e2;
+
+                        return n1.getName().compareTo(n2.getName());
+
+                    }
+                });
+                columns.add(column);
+                column = new TmfTreeColumnData(COLUMN_NAMES[1]);
+                column.setAlignment(SWT.RIGHT);
+                column.setComparator(new ViewerComparator() {
+                    @Override
+                    public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
+                        if ((e1 == null) || (e2 == null)) {
+                            return 0;
+                        }
+
+                        SegmentStoreStatisticsEntry n1 = (SegmentStoreStatisticsEntry) e1;
+                        SegmentStoreStatisticsEntry n2 = (SegmentStoreStatisticsEntry) e2;
+
+                        return Long.compare(n1.getEntry().getMin(), n2.getEntry().getMin());
+
+                    }
+                });
+                columns.add(column);
+                column = new TmfTreeColumnData(COLUMN_NAMES[2]);
+                column.setAlignment(SWT.RIGHT);
+                column.setComparator(new ViewerComparator() {
+                    @Override
+                    public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
+                        if ((e1 == null) || (e2 == null)) {
+                            return 0;
+                        }
+
+                        SegmentStoreStatisticsEntry n1 = (SegmentStoreStatisticsEntry) e1;
+                        SegmentStoreStatisticsEntry n2 = (SegmentStoreStatisticsEntry) e2;
+
+                        return Long.compare(n1.getEntry().getMax(), n2.getEntry().getMax());
+
+                    }
+                });
+                columns.add(column);
+                column = new TmfTreeColumnData(COLUMN_NAMES[3]);
+                column.setAlignment(SWT.RIGHT);
+                column.setComparator(new ViewerComparator() {
+                    @Override
+                    public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
+                        if ((e1 == null) || (e2 == null)) {
+                            return 0;
+                        }
+
+                        SegmentStoreStatisticsEntry n1 = (SegmentStoreStatisticsEntry) e1;
+                        SegmentStoreStatisticsEntry n2 = (SegmentStoreStatisticsEntry) e2;
+
+                        return Double.compare(n1.getEntry().getAverage(), n2.getEntry().getAverage());
+
+                    }
+                });
+                columns.add(column);
+                column = new TmfTreeColumnData(COLUMN_NAMES[4]);
+                column.setAlignment(SWT.RIGHT);
+                column.setComparator(new ViewerComparator() {
+                    @Override
+                    public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
+                        if ((e1 == null) || (e2 == null)) {
+                            return 0;
+                        }
+
+                        SegmentStoreStatisticsEntry n1 = (SegmentStoreStatisticsEntry) e1;
+                        SegmentStoreStatisticsEntry n2 = (SegmentStoreStatisticsEntry) e2;
+
+                        return Double.compare(n1.getEntry().getStdDev(), n2.getEntry().getStdDev());
+
+                    }
+                });
+                columns.add(column);
+                column = new TmfTreeColumnData(""); //$NON-NLS-1$
+                columns.add(column);
+                return columns;
+            }
+
+        };
+    }
+
+    @Override
+    public void initializeDataSource() {
+        ITmfTrace trace = getTrace();
+        if (trace != null) {
+            TmfAbstractAnalysisModule module = createStatisticsAnalysiModule();
+            if (module == null) {
+                return;
+            }
+            try {
+                module.setTrace(trace);
+                module.schedule();
+                fModule = module;
+            } catch (TmfAnalysisException e) {
+                Activator.getDefault().logError("Error initializing statistics analysis module", e); //$NON-NLS-1$
+            }
+        }
+    }
+
+    /**
+     * Formats a double value string
+     *
+     * @param value
+     *            a value to format
+     * @return formatted value
+     */
+    protected static String toFormattedString(double value) {
+        // The cast to long is needed because the formatter cannot truncate the
+        // number.
+        String percentageString = String.format("%s", FORMATTER.format(value)); //$NON-NLS-1$
+        return percentageString;
+    }
+
+    /**
+     * Class for defining an entry in the statistics tree.
+     */
+    protected class SegmentStoreStatisticsEntry extends TmfTreeViewerEntry {
+
+        private final SegmentStoreStatistics fEntry;
+
+        /**
+         * Constructor
+         *
+         * @param name
+         *            name of entry
+         *
+         * @param entry
+         *            segment store statistics object
+         */
+        public SegmentStoreStatisticsEntry(String name, SegmentStoreStatistics entry) {
+            super(name);
+            fEntry = entry;
+        }
+
+        /**
+         * Gets the statistics object
+         *
+         * @return statistics object
+         */
+        public SegmentStoreStatistics getEntry() {
+            return fEntry;
+        }
+
+    }
+
+    /**
+     * Class to define a level in the tree that doesn't have any values.
+     */
+    protected class HiddenTreeViewerEntry extends SegmentStoreStatisticsEntry {
+        /**
+         * Constructor
+         *
+         * @param name
+         *            the name of the level
+         */
+        public HiddenTreeViewerEntry(String name) {
+            super(name, new SegmentStoreStatistics());
+        }
+    }
+
+}
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/statistics/Messages.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/statistics/Messages.java
new file mode 100644 (file)
index 0000000..9752956
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Bernd Hufmann - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.statistics;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Messages used in the LTTng kernel CPU usage view and viewers.
+ *
+ * @author Bernd Hufmann
+ */
+@NonNullByDefault({})
+public class Messages extends NLS {
+
+    private static final String BUNDLE_NAME = "org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.statistics.messages"; //$NON-NLS-1$
+
+    /** Name of level column */
+    public static String SegmentStoreStatistics_LevelLabel;
+    /** Name of the minimum column */
+    public static String SegmentStoreStatistics_Statistics_MinLabel;
+    /** Name of maximum column */
+    public static String SegmentStoreStatistics_MaxLabel;
+    /** Name of average column */
+    public static String SegmentStoreStatistics_AverageLabel;
+    /** Name of average column */
+    public static String SegmentStoreStatisticsViewer_StandardDeviation;
+
+    static {
+        // initialize resource bundle
+        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+    }
+
+    private Messages() {
+    }
+}
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/statistics/messages.properties b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/statistics/messages.properties
new file mode 100644 (file)
index 0000000..61c5df5
--- /dev/null
@@ -0,0 +1,16 @@
+###############################################################################
+# Copyright (c) 2015, 2016 Ericsson
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     Bernd Hufmann - Initial API and implementation
+###############################################################################
+SegmentStoreStatistics_LevelLabel=Level
+SegmentStoreStatistics_Statistics_MinLabel=Minimum
+SegmentStoreStatistics_MaxLabel=Maximum
+SegmentStoreStatistics_AverageLabel=Average
+SegmentStoreStatisticsViewer_StandardDeviation=Standard Deviation
\ No newline at end of file
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/statistics/package-info.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/statistics/package-info.java
new file mode 100644 (file)
index 0000000..c352cf5
--- /dev/null
@@ -0,0 +1,11 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+@org.eclipse.jdt.annotation.NonNullByDefault
+package org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.statistics;
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/statistics/AbstractSegmentStoreStatisticsView.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/statistics/AbstractSegmentStoreStatisticsView.java
deleted file mode 100644 (file)
index 0091163..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015, 2016 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.statistics;
-
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tracecompass.common.core.NonNullUtils;
-import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
-import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
-import org.eclipse.tracecompass.tmf.ui.views.TmfView;
-
-/**
- * Abstract view to to be extended to display segment store statistics.
- *
- * @author Bernd Hufmann
- *
- */
-public abstract class AbstractSegmentStoreStatisticsView extends TmfView {
-
-    @Nullable private AbstractSegmentStoreStatisticsViewer fStatsViewer = null;
-
-    /**
-     * Constructor
-     */
-    public AbstractSegmentStoreStatisticsView() {
-        super("StatisticsView"); //$NON-NLS-1$
-    }
-
-    @Override
-    public void createPartControl(@Nullable Composite parent) {
-        super.createPartControl(parent);
-        AbstractSegmentStoreStatisticsViewer statsViewer = createSegmentStoreStatisticsViewer(NonNullUtils.checkNotNull(parent));
-        ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
-        if (trace != null) {
-            statsViewer.loadTrace(trace);
-        }
-        fStatsViewer = statsViewer;
-    }
-
-    @Override
-    public void setFocus() {
-        AbstractSegmentStoreStatisticsViewer statsViewer = fStatsViewer;
-        if (statsViewer != null) {
-            statsViewer.getControl().setFocus();
-        }
-    }
-
-    @Override
-    public void dispose() {
-        super.dispose();
-        AbstractSegmentStoreStatisticsViewer statsViewer = fStatsViewer;
-        if (statsViewer != null) {
-            statsViewer.dispose();
-        }
-    }
-
-    /**
-     * Creates a segment store statistics viewer instance.
-     *
-     * @param parent
-     *            the parent composite to create the viewer in.
-     * @return the latency statistics viewer implementation
-     */
-    protected abstract AbstractSegmentStoreStatisticsViewer createSegmentStoreStatisticsViewer(Composite parent);
-
-}
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/statistics/AbstractSegmentStoreStatisticsViewer.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/statistics/AbstractSegmentStoreStatisticsViewer.java
deleted file mode 100644 (file)
index 178ee1f..0000000
+++ /dev/null
@@ -1,298 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015, 2016 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.statistics;
-
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
-import java.text.Format;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.SubSecondTimeWithUnitFormat;
-import org.eclipse.tracecompass.internal.analysis.timing.core.segmentstore.statistics.SegmentStoreStatistics;
-import org.eclipse.tracecompass.internal.analysis.timing.ui.Activator;
-import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule;
-import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
-import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
-import org.eclipse.tracecompass.tmf.ui.viewers.tree.AbstractTmfTreeViewer;
-import org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeColumnDataProvider;
-import org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeColumnData;
-import org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeViewerEntry;
-
-/**
- * An abstract tree viewer implementation for displaying segment store
- * statistics
- *
- * @author Bernd Hufmann
- *
- */
-public abstract class AbstractSegmentStoreStatisticsViewer extends AbstractTmfTreeViewer {
-
-    private static final Format FORMATTER = new SubSecondTimeWithUnitFormat();
-
-    @Nullable
-    private TmfAbstractAnalysisModule fModule;
-
-    private static final String[] COLUMN_NAMES = new String[] {
-            checkNotNull(Messages.SegmentStoreStatistics_LevelLabel),
-            checkNotNull(Messages.SegmentStoreStatistics_Statistics_MinLabel),
-            checkNotNull(Messages.SegmentStoreStatistics_MaxLabel),
-            checkNotNull(Messages.SegmentStoreStatistics_AverageLabel),
-            checkNotNull(Messages.SegmentStoreStatisticsViewer_StandardDeviation)
-    };
-
-    /**
-     * Constructor
-     *
-     * @param parent
-     *            the parent composite
-     */
-    public AbstractSegmentStoreStatisticsViewer(Composite parent) {
-        super(parent, false);
-        setLabelProvider(new SegmentStoreStatisticsLabelProvider());
-    }
-
-    /** Provides label for the Segment Store tree viewer cells */
-    protected static class SegmentStoreStatisticsLabelProvider extends TreeLabelProvider {
-
-        @Override
-        public String getColumnText(@Nullable Object element, int columnIndex) {
-            String value = ""; //$NON-NLS-1$
-            if (element instanceof HiddenTreeViewerEntry) {
-                if (columnIndex == 0) {
-                    value = ((HiddenTreeViewerEntry) element).getName();
-                }
-            } else if (element instanceof SegmentStoreStatisticsEntry) {
-                SegmentStoreStatisticsEntry entry = (SegmentStoreStatisticsEntry) element;
-                if (columnIndex == 0) {
-                    return String.valueOf(entry.getName());
-                }
-                if (entry.getEntry().getNbSegments() > 0) {
-                    if (columnIndex == 1) {
-                        value = toFormattedString(entry.getEntry().getMin());
-                    } else if (columnIndex == 2) {
-                        value = String.valueOf(toFormattedString(entry.getEntry().getMax()));
-                    } else if (columnIndex == 3) {
-                        value = String.valueOf(toFormattedString(entry.getEntry().getAverage()));
-                    } else if (columnIndex == 4) {
-                        value = String.valueOf(toFormattedString(entry.getEntry().getStdDev()));
-                    }
-                }
-            }
-            return checkNotNull(value);
-        }
-    }
-
-    /**
-     * Creates the statistics analysis module
-     *
-     * @return the statistics analysis module
-     */
-    @Nullable
-    protected abstract TmfAbstractAnalysisModule createStatisticsAnalysiModule();
-
-    /**
-     * Gets the statistics analysis module
-     *
-     * @return the statistics analysis module
-     */
-    @Nullable
-    public TmfAbstractAnalysisModule getStatisticsAnalysisModule() {
-        return fModule;
-    }
-
-    @Override
-    protected ITmfTreeColumnDataProvider getColumnDataProvider() {
-        return new ITmfTreeColumnDataProvider() {
-
-            @Override
-            public List<@Nullable TmfTreeColumnData> getColumnData() {
-                /* All columns are sortable */
-                List<@Nullable TmfTreeColumnData> columns = new ArrayList<>();
-                TmfTreeColumnData column = new TmfTreeColumnData(COLUMN_NAMES[0]);
-                column.setAlignment(SWT.RIGHT);
-                column.setComparator(new ViewerComparator() {
-                    @Override
-                    public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
-                        if ((e1 == null) || (e2 == null)) {
-                            return 0;
-                        }
-
-                        SegmentStoreStatisticsEntry n1 = (SegmentStoreStatisticsEntry) e1;
-                        SegmentStoreStatisticsEntry n2 = (SegmentStoreStatisticsEntry) e2;
-
-                        return n1.getName().compareTo(n2.getName());
-
-                    }
-                });
-                columns.add(column);
-                column = new TmfTreeColumnData(COLUMN_NAMES[1]);
-                column.setAlignment(SWT.RIGHT);
-                column.setComparator(new ViewerComparator() {
-                    @Override
-                    public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
-                        if ((e1 == null) || (e2 == null)) {
-                            return 0;
-                        }
-
-                        SegmentStoreStatisticsEntry n1 = (SegmentStoreStatisticsEntry) e1;
-                        SegmentStoreStatisticsEntry n2 = (SegmentStoreStatisticsEntry) e2;
-
-                        return Long.compare(n1.getEntry().getMin(), n2.getEntry().getMin());
-
-                    }
-                });
-                columns.add(column);
-                column = new TmfTreeColumnData(COLUMN_NAMES[2]);
-                column.setAlignment(SWT.RIGHT);
-                column.setComparator(new ViewerComparator() {
-                    @Override
-                    public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
-                        if ((e1 == null) || (e2 == null)) {
-                            return 0;
-                        }
-
-                        SegmentStoreStatisticsEntry n1 = (SegmentStoreStatisticsEntry) e1;
-                        SegmentStoreStatisticsEntry n2 = (SegmentStoreStatisticsEntry) e2;
-
-                        return Long.compare(n1.getEntry().getMax(), n2.getEntry().getMax());
-
-                    }
-                });
-                columns.add(column);
-                column = new TmfTreeColumnData(COLUMN_NAMES[3]);
-                column.setAlignment(SWT.RIGHT);
-                column.setComparator(new ViewerComparator() {
-                    @Override
-                    public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
-                        if ((e1 == null) || (e2 == null)) {
-                            return 0;
-                        }
-
-                        SegmentStoreStatisticsEntry n1 = (SegmentStoreStatisticsEntry) e1;
-                        SegmentStoreStatisticsEntry n2 = (SegmentStoreStatisticsEntry) e2;
-
-                        return Double.compare(n1.getEntry().getAverage(), n2.getEntry().getAverage());
-
-                    }
-                });
-                columns.add(column);
-                column = new TmfTreeColumnData(COLUMN_NAMES[4]);
-                column.setAlignment(SWT.RIGHT);
-                column.setComparator(new ViewerComparator() {
-                    @Override
-                    public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
-                        if ((e1 == null) || (e2 == null)) {
-                            return 0;
-                        }
-
-                        SegmentStoreStatisticsEntry n1 = (SegmentStoreStatisticsEntry) e1;
-                        SegmentStoreStatisticsEntry n2 = (SegmentStoreStatisticsEntry) e2;
-
-                        return Double.compare(n1.getEntry().getStdDev(), n2.getEntry().getStdDev());
-
-                    }
-                });
-                columns.add(column);
-                column = new TmfTreeColumnData(""); //$NON-NLS-1$
-                columns.add(column);
-                return columns;
-            }
-
-        };
-    }
-
-    @Override
-    public void initializeDataSource() {
-        ITmfTrace trace = getTrace();
-        if (trace != null) {
-            TmfAbstractAnalysisModule module = createStatisticsAnalysiModule();
-            if (module == null) {
-                return;
-            }
-            try {
-                module.setTrace(trace);
-                module.schedule();
-                fModule = module;
-            } catch (TmfAnalysisException e) {
-                Activator.getDefault().logError("Error initializing statistics analysis module", e); //$NON-NLS-1$
-            }
-        }
-    }
-
-    /**
-     * Formats a double value string
-     *
-     * @param value
-     *            a value to format
-     * @return formatted value
-     */
-    protected static String toFormattedString(double value) {
-        // The cast to long is needed because the formatter cannot truncate the
-        // number.
-        String percentageString = String.format("%s", FORMATTER.format(value)); //$NON-NLS-1$
-        return percentageString;
-    }
-
-    /**
-     * Class for defining an entry in the statistics tree.
-     */
-    protected class SegmentStoreStatisticsEntry extends TmfTreeViewerEntry {
-
-        private SegmentStoreStatistics fEntry;
-
-        /**
-         * Constructor
-         *
-         * @param name
-         *            name of entry
-         *
-         * @param entry
-         *            segment store statistics object
-         */
-        public SegmentStoreStatisticsEntry(String name, SegmentStoreStatistics entry) {
-            super(name);
-            fEntry = entry;
-        }
-
-        /**
-         * Gets the statistics object
-         *
-         * @return statistics object
-         */
-        public SegmentStoreStatistics getEntry() {
-            return fEntry;
-        }
-
-    }
-
-    /**
-     * Class to define a level in the tree that doesn't have any values.
-     */
-    protected class HiddenTreeViewerEntry extends SegmentStoreStatisticsEntry {
-        /**
-         * Constructor
-         *
-         * @param name
-         *            the name of the level
-         */
-        public HiddenTreeViewerEntry(String name) {
-            super(name, new SegmentStoreStatistics());
-        }
-    }
-
-}
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/statistics/Messages.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/statistics/Messages.java
deleted file mode 100644 (file)
index 1494f4b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015, 2016 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *   Bernd Hufmann - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.statistics;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Messages used in the LTTng kernel CPU usage view and viewers.
- *
- * @author Bernd Hufmann
- */
-@NonNullByDefault({})
-public class Messages extends NLS {
-
-    private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.statistics.messages"; //$NON-NLS-1$
-
-    /** Name of level column */
-    public static String SegmentStoreStatistics_LevelLabel;
-    /** Name of the minimum column */
-    public static String SegmentStoreStatistics_Statistics_MinLabel;
-    /** Name of maximum column */
-    public static String SegmentStoreStatistics_MaxLabel;
-    /** Name of average column */
-    public static String SegmentStoreStatistics_AverageLabel;
-    /** Name of average column */
-    public static String SegmentStoreStatisticsViewer_StandardDeviation;
-
-    static {
-        // initialize resource bundle
-        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
-    }
-
-    private Messages() {
-    }
-}
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/statistics/messages.properties b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/statistics/messages.properties
deleted file mode 100644 (file)
index 61c5df5..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-###############################################################################
-# Copyright (c) 2015, 2016 Ericsson
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-#     Bernd Hufmann - Initial API and implementation
-###############################################################################
-SegmentStoreStatistics_LevelLabel=Level
-SegmentStoreStatistics_Statistics_MinLabel=Minimum
-SegmentStoreStatistics_MaxLabel=Maximum
-SegmentStoreStatistics_AverageLabel=Average
-SegmentStoreStatisticsViewer_StandardDeviation=Standard Deviation
\ No newline at end of file
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/statistics/package-info.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/statistics/package-info.java
deleted file mode 100644 (file)
index ed72c6e..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015, 2016 Ericsson
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-
-@org.eclipse.jdt.annotation.NonNullByDefault
-package org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.statistics;
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/pattern/stateprovider/XmlPatternLatencyStatisticsAnalysis.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/pattern/stateprovider/XmlPatternLatencyStatisticsAnalysis.java
new file mode 100644 (file)
index 0000000..dd6e5f3
--- /dev/null
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2016 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider;
+import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.AbstractSegmentStatisticsAnalysis;
+import org.eclipse.tracecompass.segmentstore.core.ISegment;
+import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlPatternSegmentBuilder;
+import org.eclipse.tracecompass.tmf.analysis.xml.core.segment.TmfXmlPatternSegment;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
+
+/**
+ * Statistic analysis for segments generated by a pattern analysis
+ *
+ * @author Jean-Christian Kouame
+ */
+public class XmlPatternLatencyStatisticsAnalysis extends AbstractSegmentStatisticsAnalysis {
+
+    private final @Nullable String fPatternAnalysisId;
+
+    /**
+     * Constructor
+     *
+     * @param patternAnalysisId
+     *            The pattern analysis ID
+     */
+    public XmlPatternLatencyStatisticsAnalysis(@Nullable String patternAnalysisId) {
+        fPatternAnalysisId = patternAnalysisId;
+    }
+
+    @Override
+    protected @Nullable String getSegmentType(@NonNull ISegment segment) {
+        if (segment instanceof TmfXmlPatternSegment) {
+            TmfXmlPatternSegment patternSegment = (TmfXmlPatternSegment) segment;
+            return patternSegment.getName().substring(TmfXmlPatternSegmentBuilder.PATTERN_SEGMENT_NAME_PREFIX.length());
+        }
+        return null;
+    }
+
+    @Override
+    protected @Nullable ISegmentStoreProvider getSegmentProviderAnalysis(@NonNull ITmfTrace trace) {
+        return fPatternAnalysisId != null ? TmfTraceUtils.getAnalysisModuleOfClass(trace, XmlPatternAnalysis.class, fPatternAnalysisId) : null;
+    }
+}
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/icons/eview16/statistics_view.gif b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/icons/eview16/statistics_view.gif
new file mode 100755 (executable)
index 0000000..d11c996
Binary files /dev/null and b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/icons/eview16/statistics_view.gif differ
index be6d59631de976fd323fefcdff92835dfd10578e..96cb5374e68fb516113d68fdd42b987caac373fa 100644 (file)
@@ -24,3 +24,4 @@ xmlxychart.view.name = XML XY Chart View
 latency.view.name = Latency Table
 latency.scatter.view.name = Latency vs Time
 latency.density.view.name = Latency vs Count
+latency.statistic.view.name = Latency Statistics
index b2dfa942e406914f9d262b4b601adfae903458c9..6a834b93b37a4ff57ccbc01a50f08f8805001441 100644 (file)
             name="%latency.density.view.name"
             restorable="true">
       </view>
+      <view
+            allowMultiple="false"
+            category="org.eclipse.linuxtools.tmf.ui.views.category"
+            class="org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency.PatternStatisticsView"
+            icon="icons/eview16/statistics_view.gif"
+            id="org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.statistics"
+            name="%latency.statistic.view.name"
+            restorable="true">
+      </view>
    </extension>
 </plugin>
index 48963e57d87bfcb54f98390f56cb055f2b2dd889..9d8af588e1e98d1e21babe7dc68c5477a20f0fc8 100644 (file)
@@ -19,6 +19,8 @@ public class Messages extends NLS {
     private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.module.messages"; //$NON-NLS-1$
     /** Density chart title */
     public static String TmfXmlAnalysisOutputSource_DensityChartTitle;
+    /** Statistics Table Title */
+    public static String TmfXmlAnalysisOutputSource_LatencyStatisticsTitle;
     /** Latency table */
     public static String TmfXmlAnalysisOutputSource_LatencyTable;
     /** Scatter graph title */
index eccaf2331ec3e965731c3384fb7c9b1dd73b6ba8..80a6ebc831910e31327c16896338bef5095e78c5 100644 (file)
@@ -7,5 +7,6 @@
 # http://www.eclipse.org/legal/epl-v10.html
 ###############################################################################
 TmfXmlAnalysisOutputSource_DensityChartTitle=Latency vs Count
+TmfXmlAnalysisOutputSource_LatencyStatisticsTitle=Latency Statistics
 TmfXmlAnalysisOutputSource_LatencyTable=Latency Table
 TmfXmlAnalysisOutputSource_ScatterGraphTitle=Latency vs Time
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternStatisticsView.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternStatisticsView.java
new file mode 100644 (file)
index 0000000..13ca84d
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.statistics.AbstractSegmentStoreStatisticsView;
+import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.statistics.AbstractSegmentStoreStatisticsViewer;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.TmfXmlUiStrings;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.XmlLatencyViewInfo;
+
+/**
+ * The statistic view for pattern latency analysis
+ *
+ * @author Jean-Christian Kouame
+ */
+public class PatternStatisticsView extends AbstractSegmentStoreStatisticsView {
+
+    private PatternStatisticsViewer fViewer;
+    /** The view's ID */
+    public static final @NonNull String ID = "org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.statistics"; //$NON-NLS-1$
+
+    private final XmlLatencyViewInfo fViewInfo = new XmlLatencyViewInfo(ID);
+
+    /**
+     * Constructor
+     */
+    public PatternStatisticsView() {
+        this.addPartPropertyListener(new IPropertyChangeListener() {
+            @Override
+            public void propertyChange(PropertyChangeEvent event) {
+                if (event.getProperty().equals(TmfXmlUiStrings.XML_LATENCY_OUTPUT_DATA)) {
+                    Object newValue = event.getNewValue();
+                    if (newValue instanceof String) {
+                        String data = (String) newValue;
+                        fViewInfo.setViewData(data);
+                        loadStatisticView();
+                    }
+                }
+            }
+        });
+    }
+
+    private void loadStatisticView() {
+        if (fViewer != null) {
+            fViewer.updateViewer(fViewInfo.getViewAnalysisId());
+        }
+    }
+
+    @Override
+    protected @NonNull AbstractSegmentStoreStatisticsViewer createSegmentStoreStatisticsViewer(@NonNull Composite parent) {
+        PatternStatisticsViewer viewer = new PatternStatisticsViewer(parent);
+        fViewer = viewer;
+        loadStatisticView();
+        return viewer;
+    }
+}
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternStatisticsViewer.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternStatisticsViewer.java
new file mode 100644 (file)
index 0000000..a0a6f16
--- /dev/null
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency;
+
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.SegmentStoreStatistics;
+import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.statistics.AbstractSegmentStoreStatisticsViewer;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternLatencyStatisticsAnalysis;
+import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule;
+import org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry;
+import org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeViewerEntry;
+
+/**
+ * A tree viewer implementation for displaying pattern latency statistics
+ *
+ * @author Jean-Christian Kouame
+ */
+public class PatternStatisticsViewer extends AbstractSegmentStoreStatisticsViewer {
+
+    private String fAnalysisId;
+
+    private static final @NonNull String PATTERN_SEGMENTS_LEVEL = "Pattern Segments"; //$NON-NLS-1$
+
+    /**
+     * Constructor
+     *
+     * @param parent
+     *            The parent composite
+     */
+    public PatternStatisticsViewer(@NonNull Composite parent) {
+        super(parent);
+    }
+
+    @Override
+    protected @Nullable TmfAbstractAnalysisModule createStatisticsAnalysiModule() {
+        return new XmlPatternLatencyStatisticsAnalysis(fAnalysisId);
+    }
+
+    @Override
+    protected ITmfTreeViewerEntry updateElements(long start, long end, boolean isSelection) {
+        if (isSelection || (start == end)) {
+            return null;
+        }
+
+        TmfAbstractAnalysisModule analysisModule = getStatisticsAnalysisModule();
+
+        if (getTrace() == null || !(analysisModule instanceof XmlPatternLatencyStatisticsAnalysis)) {
+            return null;
+        }
+
+        XmlPatternLatencyStatisticsAnalysis module = (XmlPatternLatencyStatisticsAnalysis) analysisModule;
+
+        module.waitForCompletion();
+
+        TmfTreeViewerEntry root = new TmfTreeViewerEntry(""); //$NON-NLS-1$
+        final SegmentStoreStatistics entry = module.getTotalStats();
+        if (entry != null) {
+
+            List<ITmfTreeViewerEntry> entryList = root.getChildren();
+
+            TmfTreeViewerEntry child = new SegmentStoreStatisticsEntry(checkNotNull("Total"), entry); //$NON-NLS-1$
+            entryList.add(child);
+            HiddenTreeViewerEntry segments = new HiddenTreeViewerEntry(PATTERN_SEGMENTS_LEVEL);
+            child.addChild(segments);
+
+            final Map<@NonNull String, @NonNull SegmentStoreStatistics> perTypeStats = module.getPerSegmentTypeStats();
+            if (perTypeStats != null) {
+                for (Entry<@NonNull String, @NonNull SegmentStoreStatistics> statsEntry : perTypeStats.entrySet()) {
+                    segments.addChild(new SegmentStoreStatisticsEntry(statsEntry.getKey(), statsEntry.getValue()));
+                }
+            }
+        }
+        return root;
+    }
+
+    /**
+     * Set the analysis ID and update the view
+     *
+     * @param analysisId
+     *            The analysis ID
+     */
+    public void updateViewer(String analysisId) {
+        if (analysisId != null) {
+            fAnalysisId = analysisId;
+            initializeDataSource();
+        }
+    }
+
+}
index 197718a66f5f7baf8836b5926dfca3e79e0d340b..c216127ac50d8b97bdc4b20e2695b1bdd5976b31 100644 (file)
@@ -29,6 +29,7 @@ import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.module.Messages;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency.PatternDensityView;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency.PatternLatencyTableView;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency.PatternScatterGraphView;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency.PatternStatisticsView;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.xychart.XmlXYView;
 import org.eclipse.tracecompass.tmf.analysis.xml.core.module.XmlUtils;
 import org.eclipse.tracecompass.tmf.analysis.xml.core.stateprovider.TmfXmlStrings;
@@ -110,7 +111,12 @@ public class TmfXmlAnalysisOutputSource implements ITmfNewAnalysisModuleListener
         /**
          * Latency Density View type
          */
-        DENSITY_VIEW(PatternDensityView.ID, Messages.TmfXmlAnalysisOutputSource_DensityChartTitle);
+        DENSITY_VIEW(PatternDensityView.ID, Messages.TmfXmlAnalysisOutputSource_DensityChartTitle),
+
+        /**
+         * Latency Statistic View type
+         */
+        STATISTIC_VIEW(PatternStatisticsView.ID, Messages.TmfXmlAnalysisOutputSource_LatencyStatisticsTitle);
 
         private @NonNull String fLatencyViewId;
         private String fLatencyViewLabel;
This page took 0.051517 seconds and 5 git commands to generate.