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;
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.
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;
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;
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
--- /dev/null
+/*******************************************************************************
+ * 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;
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * 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);
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * 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;
+++ /dev/null
-/*******************************************************************************
- * 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;
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * 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);
- }
-}
+++ /dev/null
-/*******************************************************************************
- * 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;
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
--- /dev/null
+/*******************************************************************************
+ * 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);
+
+}
--- /dev/null
+/*******************************************************************************
+ * 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());
+ }
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * 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() {
+ }
+}
--- /dev/null
+###############################################################################
+# 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
--- /dev/null
+/*******************************************************************************
+ * 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;
+++ /dev/null
-/*******************************************************************************
- * 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);
-
-}
+++ /dev/null
-/*******************************************************************************
- * 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());
- }
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * 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() {
- }
-}
+++ /dev/null
-###############################################################################
-# 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
+++ /dev/null
-/*******************************************************************************
- * 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;
--- /dev/null
+/*******************************************************************************
+ * 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;
+ }
+}
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
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>
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 */
# 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
--- /dev/null
+/*******************************************************************************
+ * 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;
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * 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();
+ }
+ }
+
+}
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;
/**
* 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;