Commit | Line | Data |
---|---|---|
ce8319b6 BH |
1 | /******************************************************************************* |
2 | * Copyright (c) 2015 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are made | |
5 | * available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Bernd Hufmann - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | package org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency.statistics; | |
13 | ||
14 | import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; | |
15 | ||
16 | import java.util.Iterator; | |
17 | import java.util.List; | |
18 | import java.util.Map; | |
19 | import java.util.Map.Entry; | |
20 | ||
21 | import org.eclipse.jdt.annotation.Nullable; | |
22 | import org.eclipse.swt.widgets.Composite; | |
53f46dc0 | 23 | import org.eclipse.tracecompass.internal.analysis.os.linux.core.latency.statistics.SegmentStoreStatistics; |
aa65365a | 24 | import org.eclipse.tracecompass.internal.analysis.os.linux.core.latency.statistics.SystemCallLatencyStatisticsAnalysisModule; |
ce8319b6 BH |
25 | import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule; |
26 | import org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeViewerEntry; | |
27 | import org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeViewerEntry; | |
28 | ||
29 | /** | |
30 | * A tree viewer implementation for displaying latency statistics | |
31 | * | |
32 | * @author Bernd Hufmann | |
33 | * | |
34 | */ | |
aa65365a | 35 | public class SystemCallLatencyStatisticsViewer extends AbstractSegmentStoreStatisticsViewer { |
ce8319b6 BH |
36 | |
37 | private static final String SYSCALL_LEVEL = checkNotNull(Messages.LatencyStatistics_SyscallLevelName); | |
38 | ||
39 | /** | |
40 | * Constructor | |
41 | * | |
42 | * @param parent | |
43 | * the parent composite | |
44 | */ | |
aa65365a | 45 | public SystemCallLatencyStatisticsViewer(Composite parent) { |
ce8319b6 BH |
46 | super(parent); |
47 | } | |
48 | ||
49 | /** | |
50 | * Gets the statistics analysis module | |
51 | * | |
52 | * @return the statistics analysis module | |
53 | */ | |
54 | @Override | |
55 | @Nullable protected TmfAbstractAnalysisModule createStatisticsAnalysiModule() { | |
aa65365a | 56 | SystemCallLatencyStatisticsAnalysisModule module = new SystemCallLatencyStatisticsAnalysisModule(); |
ce8319b6 BH |
57 | return module; |
58 | } | |
59 | ||
60 | @Override | |
61 | @Nullable protected ITmfTreeViewerEntry updateElements(long start, long end, boolean isSelection) { | |
62 | if (isSelection || (start == end)) { | |
63 | return null; | |
64 | } | |
65 | ||
66 | TmfAbstractAnalysisModule analysisModule = getStatisticsAnalysisModule(); | |
67 | ||
aa65365a | 68 | if (getTrace() == null || !(analysisModule instanceof SystemCallLatencyStatisticsAnalysisModule)) { |
ce8319b6 BH |
69 | return null; |
70 | } | |
71 | ||
aa65365a | 72 | SystemCallLatencyStatisticsAnalysisModule module = (SystemCallLatencyStatisticsAnalysisModule) analysisModule; |
ce8319b6 BH |
73 | |
74 | module.waitForCompletion(); | |
75 | ||
53f46dc0 | 76 | SegmentStoreStatistics entry = module.getTotalStats(); |
ce8319b6 BH |
77 | |
78 | TmfTreeViewerEntry root = new TmfTreeViewerEntry(""); //$NON-NLS-1$ | |
79 | List<ITmfTreeViewerEntry> entryList = root.getChildren(); | |
80 | ||
53f46dc0 | 81 | TmfTreeViewerEntry child = new SegmentStoreStatisticsEntry(checkNotNull(Messages.LatencyStatistics_TotalLabel), checkNotNull(entry)); |
ce8319b6 BH |
82 | entryList.add(child); |
83 | ||
3507ca88 | 84 | HiddenTreeViewerEntry syscalls = new HiddenTreeViewerEntry(checkNotNull(SYSCALL_LEVEL)); |
ce8319b6 BH |
85 | child.addChild(syscalls); |
86 | ||
53f46dc0 | 87 | Map<String, SegmentStoreStatistics> perSyscallStats = module.getPerSyscallStats(); |
3507ca88 | 88 | if (perSyscallStats != null) { |
53f46dc0 | 89 | Iterator<Entry<String, SegmentStoreStatistics>> stats = perSyscallStats.entrySet().iterator(); |
3507ca88 | 90 | while (stats.hasNext()) { |
53f46dc0 | 91 | Entry<String, SegmentStoreStatistics> statsEntry = stats.next(); |
df2597e0 | 92 | syscalls.addChild(new SegmentStoreStatisticsEntry(statsEntry.getKey(), statsEntry.getValue())); |
3507ca88 | 93 | } |
ce8319b6 BH |
94 | } |
95 | return root; | |
96 | } | |
97 | ||
98 | } |