org.eclipse.tracecompass.analysis.os.linux.core.model,
org.eclipse.tracecompass.analysis.os.linux.core.trace,
org.eclipse.tracecompass.internal.analysis.os.linux.core;x-internal:=true,
- org.eclipse.tracecompass.internal.analysis.os.linux.core.kernelanalysis;x-friends:="org.eclipse.tracecompass.analysis.os.linux.core.tests"
+ org.eclipse.tracecompass.internal.analysis.os.linux.core.kernelanalysis;x-friends:="org.eclipse.tracecompass.analysis.os.linux.core.tests",
+ org.eclipse.tracecompass.internal.analysis.os.linux.core.latency.statistics;x-friends:="org.eclipse.tracecompass.analysis.os.linux.ui"
analysis.cpuusage = CPU usage
analysis.latency = Latency Analysis
-
</module>
<module
analysis_module="org.eclipse.tracecompass.analysis.os.linux.core.latency.LatencyAnalysis"
- automatic="false"
+ automatic="true"
id="org.eclipse.tracecompass.analysis.os.linux.latency"
name="%analysis.latency">
<tracetype
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 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.os.linux.core.latency.statistics;
+
+import org.eclipse.tracecompass.segmentstore.core.ISegment;
+
+/**
+ * Class to calculate simple latency statistics (min, max, average)
+ *
+ * @author Bernd Hufmann
+ */
+public class LatencyStatistics {
+ private long fMin;
+ private long fMax;
+ private long fSum;
+ private long fNbSegments;
+
+ /**
+ * Constructor
+ */
+ public LatencyStatistics() {
+ this.fMin = Long.MAX_VALUE;
+ this.fMax = Long.MIN_VALUE;
+ this.fSum = 0;
+ this.fNbSegments = 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 ((double) fSum) / fNbSegments;
+ }
+
+ /**
+ * Update the statistics based on a given segment
+ *
+ * @param segment
+ * the segment used for the update
+ */
+ public void update (ISegment segment) {
+ long value = segment.getLength();
+ fMin = Math.min(fMin, value);
+ fMax = Math.max(fMax, value);
+ fSum += value;
+ fNbSegments++;
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 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.os.linux.core.latency.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.os.linux.core.latency.LatencyAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.latency.SystemCall;
+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 org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Analysis module to calculate statistics of a latency analysis
+ *
+ * @author Bernd Hufmann
+ */
+public class LatencyStatisticsAnalysisModule extends TmfAbstractAnalysisModule {
+
+ /** The analysis module ID */
+ public static String ID = "org.eclipse.tracecompass.analysis.os.linux.core.latency.statistics"; //$NON-NLS-1$
+
+ private @Nullable LatencyAnalysis fLatencyModule;
+
+ private @Nullable LatencyStatistics fTotalStats;
+
+ private Map<String, LatencyStatistics> fPerSyscallStats = new HashMap<>();
+
+ @Override
+ protected Iterable<IAnalysisModule> getDependentAnalyses() {
+ ITmfTrace trace = getTrace();
+ if (trace != null) {
+ LatencyAnalysis module = TmfTraceUtils.getAnalysisModuleOfClass(trace, LatencyAnalysis.class, LatencyAnalysis.ID);
+ fLatencyModule = module;
+ return checkNotNull(ImmutableList.of((IAnalysisModule) module));
+ }
+ return super.getDependentAnalyses();
+ }
+
+ @Override
+ protected boolean executeAnalysis(IProgressMonitor monitor) throws TmfAnalysisException {
+ LatencyAnalysis latency = fLatencyModule;
+ ITmfTrace trace = getTrace();
+ if ((latency == null) || (trace == null)) {
+ return false;
+ }
+ latency.waitForCompletion();
+
+ ISegmentStore<ISegment> store = latency.getResults();
+
+ if (store != null) {
+
+ boolean result = calculateTotalManual(store, monitor);
+
+ if (!result) {
+ return false;
+ }
+
+ result = calculateTotalPerSyscall(store, monitor);
+ if (!result) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean calculateTotalManual(ISegmentStore<ISegment> store, IProgressMonitor monitor) {
+ LatencyStatistics total = new LatencyStatistics();
+ 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 calculateTotalPerSyscall(ISegmentStore<ISegment> store, IProgressMonitor monitor) {
+ fPerSyscallStats = new HashMap<>();
+
+ Iterator<ISegment> iter = store.iterator();
+ while (iter.hasNext()) {
+ if (monitor.isCanceled()) {
+ return false;
+ }
+ ISegment segment = iter.next();
+ if (segment instanceof SystemCall) {
+ SystemCall syscall = (SystemCall) segment;
+ LatencyStatistics values = fPerSyscallStats.get(syscall.getName());
+ if (values == null) {
+ values = new LatencyStatistics();
+ }
+ values.update(segment);
+ fPerSyscallStats.put(syscall.getName(), values);
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ protected void canceling() {
+ }
+
+ /**
+ * The total statistics
+ *
+ * @return the total statistics
+ */
+ public @Nullable LatencyStatistics getTotalStats() {
+ return fTotalStats;
+ }
+
+ /**
+ * The per syscall statistics
+ *
+ * @return the per syscall statistics
+ */
+ public Map<String, LatencyStatistics> getPerSyscallStats() {
+ return fPerSyscallStats;
+ }
+
+ }
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 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.os.linux.core.latency.statistics;
org.eclipse.tracecompass.analysis.os.linux.ui.views.resources,
org.eclipse.tracecompass.internal.analysis.os.linux.ui;x-internal:=true,
org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency;x-internal:=true,
- org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.resources;x-internal:=true
+ org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.resources;x-internal:=true,
+ org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency.statistics;x-internal:=true
resources.view.name = Resources
cpuusage.view.name = CPU Usage
latency.view.name = Latency Analysis
-latency.scatter.view.name = Latency vs Time
\ No newline at end of file
+latency.scatter.view.name = Latency vs Time
+latency.stats.view.name = Latency Statistics
id="org.eclipse.tracecompass.analysis.os.linux.views.latency.scatter"
name="%latency.scatter.view.name"
restorable="true">
+ </view>
+ <view
+ allowMultiple="false"
+ category="org.eclipse.linuxtools.lttng2.ui.views.category"
+ class="org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency.statistics.LatencyStatisticsView"
+ icon="icons/eview16/statistics_view.gif"
+ id="org.eclipse.tracecompass.analysis.os.linux.ui.views.latency.statsview"
+ name="%latency.stats.view.name"
+ restorable="true">
</view>
</extension>
<extension
package org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency;
import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.tracecompass.analysis.os.linux.core.latency.LatencyAnalysis;
import org.eclipse.tracecompass.analysis.timing.core.segmentstore.AbstractSegmentStoreAnalysisModule;
import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.AbstractSegmentStoreTableViewer;
+import org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency.statistics.LatencyStatisticsView;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
/**
* Displays the latency analysis data in a column table
protected @Nullable AbstractSegmentStoreAnalysisModule getSegmentStoreAnalysisModule(ITmfTrace trace) {
return TmfTraceUtils.getAnalysisModuleOfClass(trace, LatencyAnalysis.class, LatencyAnalysis.ID);
}
+
+ @Override
+ protected void appendToTablePopupMenu(IMenuManager manager, IStructuredSelection sel) {
+ super.appendToTablePopupMenu(manager, sel);
+ manager.add(new Separator());
+ IAction showStatisticsAction = new Action(Messages.LatencyTable_ShowStatisticsActionName) {
+ @Override
+ public void run() {
+ final IWorkbench wb = PlatformUI.getWorkbench();
+ final IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage();
+ try {
+ activePage.showView(LatencyStatisticsView.ID);
+ } catch (PartInitException e) {
+ }
+ }
+ };
+
+ manager.add(showStatisticsAction);
+ }
}
*/
public static String LatencyView_goToEndEvent;
+ /**
+ * Name of show statistics action
+ */
+ public static String LatencyTable_ShowStatisticsActionName;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+###############################################################################
+# Copyright (c) 2015 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:
+# France Lapointe Nguyen - Initial API and implementation
+###############################################################################
LatencyScatterGraphViewer_legend=Duration
LatencyScatterView_title=Duration vs Time
LatencyScatterView_xAxis=Time (ns)
LatencyTableViewer_startTime=Start Time
LatencyView_goToStartEvent=Go to start time
LatencyView_goToEndEvent=Go to end time
+
+LatencyTable_ShowStatisticsActionName=Show statistics...
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 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.os.linux.ui.views.latency.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 latency statistics.
+ *
+ * @author Bernd Hufmann
+ *
+ */
+public abstract class AbstractLatencyStatisticsView extends TmfView {
+
+ @Nullable private AbstractLatencyStatisticsViewer fStatsViewer = null;
+
+ /**
+ * Constructor
+ */
+ public AbstractLatencyStatisticsView() {
+ super("StatisticsView"); //$NON-NLS-1$
+ }
+
+ @Override
+ public void createPartControl(@Nullable Composite parent) {
+ super.createPartControl(parent);
+ AbstractLatencyStatisticsViewer statsViewer = createLatencyStatisticsViewer(NonNullUtils.checkNotNull(parent));
+ ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
+ if (trace != null) {
+ statsViewer.loadTrace(trace);
+ }
+ fStatsViewer = statsViewer;
+ }
+
+ @Override
+ public void setFocus() {
+ AbstractLatencyStatisticsViewer statsViewer = fStatsViewer;
+ if (statsViewer != null) {
+ statsViewer.getControl().setFocus();
+ }
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ AbstractLatencyStatisticsViewer statsViewer = fStatsViewer;
+ if (statsViewer != null) {
+ statsViewer.dispose();
+ }
+ }
+
+ /**
+ * Creates a latency statistics viewer instance.
+ *
+ * @param parent
+ * the parent composite to create the viewer in.
+ * @return the latency statistics viewer implementation
+ */
+ protected abstract AbstractLatencyStatisticsViewer createLatencyStatisticsViewer(Composite parent);
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 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.os.linux.ui.views.latency.statistics;
+
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tracecompass.internal.analysis.os.linux.core.latency.statistics.LatencyStatistics;
+import org.eclipse.tracecompass.internal.analysis.os.linux.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 latency statistics
+ *
+ * @author Bernd Hufmann
+ *
+ */
+public abstract class AbstractLatencyStatisticsViewer extends AbstractTmfTreeViewer {
+
+ private static final NumberFormat FORMATTER = checkNotNull(NumberFormat.getNumberInstance(Locale.getDefault()));
+
+ @Nullable private TmfAbstractAnalysisModule fModule;
+
+ private static final String[] COLUMN_NAMES = new String[] {
+ checkNotNull(Messages.LatencyStatistics_LevelLabel),
+ checkNotNull(Messages.LatencyStatistics_MinLabel),
+ checkNotNull(Messages.LatencyStatistics_MaxLabel),
+ checkNotNull(Messages.LatencyStatistics_AverageLabel)
+ };
+
+ /**
+ * Constructor
+ *
+ * @param parent
+ * the parent composite
+ */
+ public AbstractLatencyStatisticsViewer(Composite parent) {
+ super(parent, false);
+ setLabelProvider(new LatencyLabelProvider());
+ }
+
+ /** Provides label for the Latency tree viewer cells */
+ protected static class LatencyLabelProvider 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 {
+ LatencyTreeViewerEntry obj = (LatencyTreeViewerEntry) element;
+ if (obj != null) {
+ if (columnIndex == 0) {
+ value = String.valueOf(obj.getName());
+ } else if (columnIndex == 1) {
+ value = toFormattedString(obj.getEntry().getMin());
+ } else if (columnIndex == 2) {
+ value = String.valueOf(toFormattedString(obj.getEntry().getMax()));
+ } else if (columnIndex == 3) {
+ value = String.valueOf(toFormattedString(obj.getEntry().getAverage()));
+ }
+ }
+ }
+ 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<TmfTreeColumnData> getColumnData() {
+ /* All columns are sortable */
+ List<TmfTreeColumnData> columns = new ArrayList<>();
+ TmfTreeColumnData column = new TmfTreeColumnData(COLUMN_NAMES[0]);
+ column.setComparator(new ViewerComparator() {
+ @Override
+ public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
+ if ((e1 == null) || (e2 == null)) {
+ return 0;
+ }
+
+ LatencyTreeViewerEntry n1 = (LatencyTreeViewerEntry) e1;
+ LatencyTreeViewerEntry n2 = (LatencyTreeViewerEntry) e2;
+
+ return n1.getName().compareTo(n2.getName());
+
+ }
+ });
+ columns.add(column);
+ column = new TmfTreeColumnData(COLUMN_NAMES[1]);
+ column.setComparator(new ViewerComparator() {
+ @Override
+ public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
+ if ((e1 == null) || (e2 == null)) {
+ return 0;
+ }
+
+ LatencyTreeViewerEntry n1 = (LatencyTreeViewerEntry) e1;
+ LatencyTreeViewerEntry n2 = (LatencyTreeViewerEntry) e2;
+
+ return Long.compare(n1.getEntry().getMin(), n2.getEntry().getMin());
+
+ }
+ });
+ columns.add(column);
+ column = new TmfTreeColumnData(COLUMN_NAMES[2]);
+ column.setComparator(new ViewerComparator() {
+ @Override
+ public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
+ if ((e1 == null) || (e2 == null)) {
+ return 0;
+ }
+
+ LatencyTreeViewerEntry n1 = (LatencyTreeViewerEntry) e1;
+ LatencyTreeViewerEntry n2 = (LatencyTreeViewerEntry) e2;
+
+ return Long.compare(n1.getEntry().getMax(), n2.getEntry().getMax());
+
+ }
+ });
+ columns.add(column);
+ column = new TmfTreeColumnData(COLUMN_NAMES[3]);
+ column.setComparator(new ViewerComparator() {
+ @Override
+ public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
+ if ((e1 == null) || (e2 == null)) {
+ return 0;
+ }
+
+ LatencyTreeViewerEntry n1 = (LatencyTreeViewerEntry) e1;
+ LatencyTreeViewerEntry n2 = (LatencyTreeViewerEntry) e2;
+
+ return Double.compare(n1.getEntry().getAverage(), n2.getEntry().getAverage());
+
+ }
+ });
+ columns.add(column);
+
+ return columns;
+ }
+
+ };
+ }
+
+
+ @Override
+ public void initializeDataSource() {
+ /* Should not be called while trace is still null */
+ ITmfTrace trace = checkNotNull(getTrace());
+ 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 = checkNotNull(String.format("%s", FORMATTER.format(value))); //$NON-NLS-1$
+ return percentageString;
+ }
+
+ /**
+ * Class for defining an entry in the statistics tree.
+ */
+ protected class LatencyTreeViewerEntry extends TmfTreeViewerEntry {
+ private LatencyStatistics fEntry;
+
+ /**
+ * Constructor
+ *
+ * @param name
+ * name of entry
+ *
+ * @param entry
+ * latency statistics object
+ */
+ public LatencyTreeViewerEntry(String name, LatencyStatistics entry) {
+ super(name);
+ fEntry = entry;
+ }
+
+ /**
+ * Gets the statistics object
+ *
+ * @return statistics object
+ */
+ public LatencyStatistics getEntry() {
+ return fEntry;
+ }
+
+ }
+
+ /**
+ * Class to define a level in the tree that doesn't have any values.
+ */
+ protected class HiddenTreeViewerEntry extends LatencyTreeViewerEntry {
+ /**
+ * Constructor
+ *
+ * @param name
+ * the name of the level
+ */
+ public HiddenTreeViewerEntry(String name) {
+ super(name, new LatencyStatistics());
+ }
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 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.os.linux.ui.views.latency.statistics;
+
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * View to display latency statistics.
+ *
+ * @author Bernd Hufmann
+ *
+ */
+public class LatencyStatisticsView extends AbstractLatencyStatisticsView {
+
+ /** The view ID*/
+ public static final String ID = "org.eclipse.tracecompass.analysis.os.linux.ui.views.latency.statsview"; //$NON-NLS-1$
+
+ @Override
+ protected AbstractLatencyStatisticsViewer createLatencyStatisticsViewer(Composite parent) {
+ return checkNotNull((AbstractLatencyStatisticsViewer) new LatencyStatisticsViewer(checkNotNull(parent)));
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 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.os.linux.ui.views.latency.statistics;
+
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tracecompass.internal.analysis.os.linux.core.latency.statistics.LatencyStatistics;
+import org.eclipse.tracecompass.internal.analysis.os.linux.core.latency.statistics.LatencyStatisticsAnalysisModule;
+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 latency statistics
+ *
+ * @author Bernd Hufmann
+ *
+ */
+public class LatencyStatisticsViewer extends AbstractLatencyStatisticsViewer {
+
+ private static final String SYSCALL_LEVEL = checkNotNull(Messages.LatencyStatistics_SyscallLevelName);
+
+ /**
+ * Constructor
+ *
+ * @param parent
+ * the parent composite
+ */
+ public LatencyStatisticsViewer(Composite parent) {
+ super(parent);
+ }
+
+ /**
+ * Gets the statistics analysis module
+ *
+ * @return the statistics analysis module
+ */
+ @Override
+ @Nullable protected TmfAbstractAnalysisModule createStatisticsAnalysiModule() {
+ LatencyStatisticsAnalysisModule module = new LatencyStatisticsAnalysisModule();
+ return module;
+ }
+
+ @Override
+ @Nullable protected ITmfTreeViewerEntry updateElements(long start, long end, boolean isSelection) {
+ if (isSelection || (start == end)) {
+ return null;
+ }
+
+ TmfAbstractAnalysisModule analysisModule = getStatisticsAnalysisModule();
+
+ if (getTrace() == null || !(analysisModule instanceof LatencyStatisticsAnalysisModule)) {
+ return null;
+ }
+
+ LatencyStatisticsAnalysisModule module = (LatencyStatisticsAnalysisModule) analysisModule;
+
+ module.waitForCompletion();
+
+ LatencyStatistics entry = module.getTotalStats();
+
+ TmfTreeViewerEntry root = new TmfTreeViewerEntry(""); //$NON-NLS-1$
+ List<ITmfTreeViewerEntry> entryList = root.getChildren();
+
+ TmfTreeViewerEntry child = new LatencyTreeViewerEntry(checkNotNull(Messages.LatencyStatistics_TotalLabel), checkNotNull(entry));
+ entryList.add(child);
+
+ HiddenTreeViewerEntry syscalls = new HiddenTreeViewerEntry(SYSCALL_LEVEL);
+ child.addChild(syscalls);
+
+ Map<String, LatencyStatistics> perSyscallStats = module.getPerSyscallStats();
+
+ Iterator<Entry<String, LatencyStatistics>> stats = perSyscallStats.entrySet().iterator();
+ while (stats.hasNext()) {
+ Entry<String, LatencyStatistics> statsEntry = stats.next();
+ syscalls.addChild(new LatencyTreeViewerEntry(checkNotNull(statsEntry.getKey()), checkNotNull(statsEntry.getValue())));
+ }
+ return root;
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 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.os.linux.ui.views.latency.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(false)
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency.statistics.messages"; //$NON-NLS-1$
+
+ /** Name of the system call level in statistics tree */
+ public static String LatencyStatistics_SyscallLevelName;
+ /** Name of level column */
+ public static String LatencyStatistics_LevelLabel;
+ /** Name of the minimum column */
+ public static String LatencyStatistics_MinLabel;
+ /** Name of maximum column */
+ public static String LatencyStatistics_MaxLabel;
+ /** Name of average column */
+ public static String LatencyStatistics_AverageLabel;
+ /** Name of Total statistics */
+ public static String LatencyStatistics_TotalLabel;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
--- /dev/null
+###############################################################################
+# Copyright (c) 2015 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
+###############################################################################
+
+LatencyStatistics_SyscallLevelName=System Calls
+LatencyStatistics_LevelLabel=Level
+LatencyStatistics_MinLabel=Minimum
+LatencyStatistics_MaxLabel=Maximum
+LatencyStatistics_AverageLabel=Average
+LatencyStatistics_TotalLabel=Total
+
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 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.os.linux.ui.views.latency.statistics;
org.swtchart,
com.ibm.icu,
org.eclipse.linuxtools.dataviewers.piechart,
- org.eclipse.tracecompass.segmentstore.core;bundle-version="1.0.0"
+ org.eclipse.tracecompass.segmentstore.core
Export-Package: org.eclipse.tracecompass.internal.tmf.ui;x-friends:="org.eclipse.tracecompass.tmf.ui.tests,org.eclipse.tracecompass.tmf.ctf.ui.tests",
org.eclipse.tracecompass.internal.tmf.ui.commands;x-internal:=true,
org.eclipse.tracecompass.internal.tmf.ui.dialogs;x-internal:=true,