1 /*******************************************************************************
2 * Copyright (c) 2015 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 *******************************************************************************/
12 package org
.eclipse
.tracecompass
.internal
.analysis
.os
.linux
.ui
.views
.latency
.statistics
;
14 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
16 import java
.util
.Iterator
;
17 import java
.util
.List
;
19 import java
.util
.Map
.Entry
;
21 import org
.eclipse
.jdt
.annotation
.Nullable
;
22 import org
.eclipse
.swt
.widgets
.Composite
;
23 import org
.eclipse
.tracecompass
.internal
.analysis
.os
.linux
.core
.latency
.statistics
.LatencyStatistics
;
24 import org
.eclipse
.tracecompass
.internal
.analysis
.os
.linux
.core
.latency
.statistics
.LatencyStatisticsAnalysisModule
;
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
;
30 * A tree viewer implementation for displaying latency statistics
32 * @author Bernd Hufmann
35 public class LatencyStatisticsViewer
extends AbstractSegmentStoreStatisticsViewer
{
37 private static final String SYSCALL_LEVEL
= checkNotNull(Messages
.LatencyStatistics_SyscallLevelName
);
43 * the parent composite
45 public LatencyStatisticsViewer(Composite parent
) {
50 * Gets the statistics analysis module
52 * @return the statistics analysis module
55 @Nullable protected TmfAbstractAnalysisModule
createStatisticsAnalysiModule() {
56 LatencyStatisticsAnalysisModule module
= new LatencyStatisticsAnalysisModule();
61 @Nullable protected ITmfTreeViewerEntry
updateElements(long start
, long end
, boolean isSelection
) {
62 if (isSelection
|| (start
== end
)) {
66 TmfAbstractAnalysisModule analysisModule
= getStatisticsAnalysisModule();
68 if (getTrace() == null || !(analysisModule
instanceof LatencyStatisticsAnalysisModule
)) {
72 LatencyStatisticsAnalysisModule module
= (LatencyStatisticsAnalysisModule
) analysisModule
;
74 module
.waitForCompletion();
76 LatencyStatistics entry
= module
.getTotalStats();
78 TmfTreeViewerEntry root
= new TmfTreeViewerEntry(""); //$NON-NLS-1$
79 List
<ITmfTreeViewerEntry
> entryList
= root
.getChildren();
81 TmfTreeViewerEntry child
= new LatencyTreeViewerEntry(checkNotNull(Messages
.LatencyStatistics_TotalLabel
), checkNotNull(entry
));
84 HiddenTreeViewerEntry syscalls
= new HiddenTreeViewerEntry(checkNotNull(SYSCALL_LEVEL
));
85 child
.addChild(syscalls
);
87 Map
<String
, LatencyStatistics
> perSyscallStats
= module
.getPerSyscallStats();
88 if (perSyscallStats
!= null) {
89 Iterator
<Entry
<String
, LatencyStatistics
>> stats
= perSyscallStats
.entrySet().iterator();
90 while (stats
.hasNext()) {
91 Entry
<String
, LatencyStatistics
> statsEntry
= stats
.next();
92 syscalls
.addChild(new LatencyTreeViewerEntry(checkNotNull(statsEntry
.getKey()), checkNotNull(statsEntry
.getValue())));