Skip to content

Commit 88edc0a

Browse files
author
Siwei Zhang
committed
[Not Ready] Add first endpoint
Signed-off-by: Siwei Zhang <siwei.zhang@ericsson.com>
1 parent 980bc83 commit 88edc0a

22 files changed

Lines changed: 970 additions & 96 deletions

File tree

analysis/org.eclipse.tracecompass.analysis.profiling.core/plugin.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
class="org.eclipse.tracecompass.internal.analysis.profiling.core.instrumented.FlameChartDataProviderFactory"
2020
id="org.eclipse.tracecompass.analysis.profiling.core.flamechart">
2121
</dataProviderFactory>
22+
<dataProviderFactory
23+
class="org.eclipse.tracecompass.internal.analysis.profiling.core.callstack.provider.CallStackBarChartDataProviderFactory"
24+
id="org.eclipse.tracecompass.analysis.profiling.core.callstack.barchart.provider">
25+
</dataProviderFactory>
2226
</extension>
2327
<extension
2428
point="org.eclipse.linuxtools.tmf.core.analysis">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/**********************************************************************
2+
* Copyright (c) 2025 Ericsson
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
**********************************************************************/
11+
package org.eclipse.tracecompass.internal.analysis.profiling.core.callstack.provider;
12+
13+
import java.util.ArrayList;
14+
import java.util.Collections;
15+
import java.util.List;
16+
17+
import org.eclipse.jdt.annotation.NonNull;
18+
import org.eclipse.tracecompass.analysis.profiling.core.base.IProfilingElement;
19+
import org.eclipse.tracecompass.analysis.profiling.core.callstack.CallStackAnalysis;
20+
import org.eclipse.tracecompass.analysis.profiling.core.callstack.CallStackSeries;
21+
import org.eclipse.tracecompass.common.core.NonNullUtils;
22+
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
23+
import org.eclipse.tracecompass.tmf.core.dataprovider.DataType;
24+
import org.eclipse.tracecompass.tmf.core.model.barchart.AbstractTreeBarChartDataProvider;
25+
import org.eclipse.tracecompass.tmf.core.model.barchart.AxisDomain;
26+
import org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel;
27+
import org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel;
28+
import org.eclipse.tracecompass.tmf.core.model.xy.TmfXYAxisDescription;
29+
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
30+
31+
/**
32+
* Bar chart provider to show function duration distributions in the call stack.
33+
*
34+
* @author Siwei Zhang
35+
* @since 2.6
36+
*/
37+
public class CallStackBarChartDataProvider extends AbstractTreeBarChartDataProvider<@NonNull CallStackAnalysis, @NonNull ITmfTreeDataModel> {
38+
39+
/**
40+
* Provider id.
41+
*/
42+
public static final String ID = "org.eclipse.tracecompass.analysis.profiling.core.callstack.barchart.provider"; //$NON-NLS-1$
43+
44+
private static final String EXECUTION_TIME = "Execution Time"; //$NON-NLS-1$
45+
private static final String NUMBER_OF_EXECUTIONS = "Number of Executions"; //$NON-NLS-1$
46+
private static final String UNIT_NS = "ns"; //$NON-NLS-1$
47+
private static final String UNIT_EMPTY = ""; //$NON-NLS-1$
48+
49+
private CallStackAnalysis fModule;
50+
51+
/**
52+
* Constructor.
53+
*
54+
* @param trace
55+
* The trace associated with this data provider
56+
* @param analysisModule
57+
* The analysis module used to compute data
58+
*/
59+
public CallStackBarChartDataProvider(@NonNull ITmfTrace trace, @NonNull CallStackAnalysis analysisModule) {
60+
super(trace, analysisModule);
61+
fModule = analysisModule;
62+
}
63+
64+
@Override
65+
public TmfXYAxisDescription getXAxisDescription() {
66+
ITmfStateSystem ss = fModule.getStateSystem();
67+
68+
if (ss != null) {
69+
return new TmfXYAxisDescription(
70+
EXECUTION_TIME, UNIT_NS, DataType.DURATION, new AxisDomain.TimeRange(ss.getStartTime(), ss.getCurrentEndTime()));
71+
}
72+
return new TmfXYAxisDescription(
73+
EXECUTION_TIME, UNIT_NS, DataType.DURATION, new AxisDomain.TimeRange(-1, -1));
74+
}
75+
76+
@Override
77+
public TmfXYAxisDescription getYAxisDescription() {
78+
return new TmfXYAxisDescription(
79+
NUMBER_OF_EXECUTIONS, UNIT_EMPTY, DataType.NUMBER);
80+
}
81+
82+
@Override
83+
public String getId() {
84+
return ID;
85+
}
86+
87+
@Override
88+
protected boolean isCacheable() {
89+
return false;
90+
}
91+
92+
@Override
93+
protected List<ITmfTreeDataModel> getEntries() {
94+
CallStackSeries series = fModule.getCallStackSeries();
95+
if (series == null) {
96+
return Collections.EMPTY_LIST;
97+
}
98+
99+
List<ITmfTreeDataModel> entries = new ArrayList<>();
100+
long rootId = getEntryId();
101+
entries.add(new TmfTreeDataModel(-1, rootId, NonNullUtils.nullToEmptyString(getTrace().getName())));
102+
for(IProfilingElement element : series.getRootElements()) {
103+
entries.add(new TmfTreeDataModel(rootId, getEntryId(), element.getName()));
104+
}
105+
return entries;
106+
}
107+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/**********************************************************************
2+
* Copyright (c) 2025 Ericsson
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
**********************************************************************/
11+
package org.eclipse.tracecompass.internal.analysis.profiling.core.callstack.provider;
12+
13+
import java.util.ArrayList;
14+
import java.util.Collection;
15+
import java.util.Collections;
16+
import java.util.Iterator;
17+
import java.util.List;
18+
import java.util.Objects;
19+
20+
import org.eclipse.jdt.annotation.NonNull;
21+
import org.eclipse.jdt.annotation.Nullable;
22+
import org.eclipse.tracecompass.analysis.profiling.core.callstack.CallStackAnalysis;
23+
import org.eclipse.tracecompass.tmf.core.dataprovider.IDataProviderDescriptor;
24+
import org.eclipse.tracecompass.tmf.core.dataprovider.IDataProviderDescriptor.ProviderType;
25+
import org.eclipse.tracecompass.tmf.core.dataprovider.IDataProviderFactory;
26+
import org.eclipse.tracecompass.tmf.core.model.DataProviderDescriptor;
27+
import org.eclipse.tracecompass.tmf.core.model.barchart.TmfTreeBarChartCompositeDataProvider;
28+
import org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel;
29+
import org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataProvider;
30+
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
31+
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
32+
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
33+
import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment;
34+
35+
import com.google.common.collect.Iterables;
36+
37+
/**
38+
* {@link CallStackBarChartDataProvider} factory.
39+
*
40+
* @author Siwei Zhang
41+
* @since 2.6
42+
*/
43+
public class CallStackBarChartDataProviderFactory implements IDataProviderFactory {
44+
45+
private static final IDataProviderDescriptor DESCRIPTOR = new DataProviderDescriptor.Builder()
46+
.setId(CallStackBarChartDataProvider.ID)
47+
.setName(Objects.requireNonNull(Messages.CallStackBarChartDataProviderFactory_title))
48+
.setDescription(Objects.requireNonNull(Messages.CallStackBarChartDataProviderFactory_descriptionText))
49+
.setProviderType(ProviderType.BAR_CHART)
50+
.build();
51+
52+
@Override
53+
public @Nullable ITmfTreeDataProvider<? extends ITmfTreeDataModel> createProvider(ITmfTrace trace) {
54+
if (trace instanceof TmfExperiment) {
55+
@NonNull List<@NonNull CallStackBarChartDataProvider> providers = new ArrayList<>();
56+
for (ITmfTrace child : TmfTraceManager.getTraceSet(trace)) {
57+
CallStackBarChartDataProvider provider = createProviderLocal(child);
58+
if (provider != null) {
59+
providers.add(provider);
60+
}
61+
}
62+
if (providers.size() == 1) {
63+
return providers.get(0);
64+
}
65+
if (!providers.isEmpty()) {
66+
return new TmfTreeBarChartCompositeDataProvider<>(providers, CallStackBarChartDataProvider.ID);
67+
}
68+
return null;
69+
}
70+
return createProviderLocal(trace);
71+
}
72+
73+
private static @Nullable CallStackBarChartDataProvider createProviderLocal(@NonNull ITmfTrace trace) {
74+
Iterator<CallStackAnalysis> modules = TmfTraceUtils.getAnalysisModulesOfClass(trace, CallStackAnalysis.class).iterator();
75+
while (modules.hasNext()) {
76+
CallStackAnalysis first = modules.next();
77+
first.schedule();
78+
return new CallStackBarChartDataProvider(trace, first);
79+
}
80+
return null;
81+
}
82+
83+
@Override
84+
public Collection<IDataProviderDescriptor> getDescriptors(@NonNull ITmfTrace trace) {
85+
Iterable<@NonNull CallStackAnalysis> modules = TmfTraceUtils.getAnalysisModulesOfClass(trace, CallStackAnalysis.class);
86+
return !Iterables.isEmpty(modules) ? Collections.singletonList(DESCRIPTOR) : Collections.emptyList();
87+
}
88+
}

analysis/org.eclipse.tracecompass.analysis.profiling.core/src/org/eclipse/tracecompass/internal/analysis/profiling/core/callstack/provider/Messages.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2013, 2014 Ericsson
2+
* Copyright (c) 2013, 2025 Ericsson
33
*
44
* All rights reserved. This program and the accompanying materials are
55
* made available under the terms of the Eclipse Public License 2.0 which
@@ -48,6 +48,15 @@ public class Messages extends NLS {
4848
*/
4949
public static @Nullable String CallStackDataProviderFactory_descriptionText;
5050

51+
/**
52+
* Name of the data provider shown to the user for bar chart
53+
*/
54+
public static @Nullable String CallStackBarChartDataProviderFactory_title;
55+
/**
56+
* Help text for the data descriptor for bar chart
57+
*/
58+
public static @Nullable String CallStackBarChartDataProviderFactory_descriptionText;
59+
5160
static {
5261
// initialize resource bundle
5362
NLS.initializeMessages(BUNDLE_NAME, Messages.class);

analysis/org.eclipse.tracecompass.analysis.profiling.core/src/org/eclipse/tracecompass/internal/analysis/profiling/core/callstack/provider/messages.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
###############################################################################
2-
# Copyright (c) 2013, 2014 Ericsson
2+
# Copyright (c) 2013, 2025 Ericsson
33
#
44
# All rights reserved. This program and the accompanying materials
55
# are made available under the terms of the Eclipse Public License 2.0
@@ -17,4 +17,6 @@ CallStackStateProvider_IncoherentCallstack=Incoherent callstack found on ({0}) o
1717
CallStackDataProvider_toolTipAddress=Address
1818
CallStackDataProvider_toolTipState=State
1919
CallStackDataProviderFactory_title=Flame Chart
20-
CallStackDataProviderFactory_descriptionText=Show a call stack over time
20+
CallStackDataProviderFactory_descriptionText=Show a call stack over time
21+
CallStackBarChartDataProviderFactory_title=Function Density View
22+
CallStackBarChartDataProviderFactory_descriptionText=Shows the distribution of function execution time

releng/org.eclipse.tracecompass.integration.core.tests/src/org/eclipse/tracecompass/integration/core/tests/dataproviders/DataProviderManagerTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,12 @@ public class DataProviderManagerTest {
273273
.setId("org.eclipse.tracecompass.internal.analysis.profiling.callstack.provider.CallStackDataProvider");
274274
EXPECTED_UST_DP_DESCRIPTORS.add(builder.build());
275275
builder = new DataProviderDescriptor.Builder();
276+
builder.setName("Function Density View")
277+
.setDescription("Shows the distribution of function execution time")
278+
.setProviderType(ProviderType.BAR_CHART)
279+
.setId("org.eclipse.tracecompass.analysis.profiling.core.callstack.barchart.provider");
280+
EXPECTED_UST_DP_DESCRIPTORS.add(builder.build());
281+
builder = new DataProviderDescriptor.Builder();
276282
builder.setName("Function Duration Statistics")
277283
.setDescription("Show the function duration statistics")
278284
.setProviderType(ProviderType.DATA_TREE)

tmf/org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %Bundle-Name
44
Bundle-Vendor: %Bundle-Vendor
5-
Bundle-Version: 10.1.0.qualifier
5+
Bundle-Version: 10.2.0.qualifier
66
Bundle-Localization: plugin
77
Bundle-SymbolicName: org.eclipse.tracecompass.tmf.core;singleton:=true
88
Bundle-Activator: org.eclipse.tracecompass.internal.tmf.core.Activator
@@ -107,6 +107,7 @@ Export-Package: org.eclipse.tracecompass.internal.provisional.tmf.core.model,
107107
org.eclipse.tracecompass.tmf.core.markers,
108108
org.eclipse.tracecompass.tmf.core.model,
109109
org.eclipse.tracecompass.tmf.core.model.annotations,
110+
org.eclipse.tracecompass.tmf.core.model.barchart,
110111
org.eclipse.tracecompass.tmf.core.model.filters,
111112
org.eclipse.tracecompass.tmf.core.model.timegraph,
112113
org.eclipse.tracecompass.tmf.core.model.tree,

tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/dataprovider/IDataProviderDescriptor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public enum ProviderType {
6161
* @since 6.1
6262
*/
6363
DATA_TREE,
64+
/**
65+
* A provider for bar chart.
66+
* @since 10.2
67+
*/
68+
BAR_CHART,
6469
/**
6570
* A provider with no data. Can be used for grouping purposes and/or as data provider configurator.
6671
* @since 9.5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**********************************************************************
2+
* Copyright (c) 2025 Ericsson
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
**********************************************************************/
11+
package org.eclipse.tracecompass.tmf.core.model.barchart;
12+
13+
import java.util.List;
14+
import java.util.Map;
15+
16+
import org.eclipse.core.runtime.IProgressMonitor;
17+
import org.eclipse.jdt.annotation.Nullable;
18+
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
19+
import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
20+
import org.eclipse.tracecompass.tmf.core.model.tree.AbstractTreeDataProvider;
21+
import org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel;
22+
import org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeModel;
23+
import org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModelWithAxisDescriptors;
24+
import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
25+
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
26+
27+
/**
28+
* Abstract base class for tree-based data providers support bar chart
29+
* visualizations.
30+
* <p>
31+
* This class extends {@link AbstractTreeDataProvider} to handle hierarchical
32+
* tree data, while also implementing {@link ITmfBarChartDataProvider} to supply
33+
* bar chart data for views. It is meant to be sub-classed by concrete providers
34+
* that use bar chart representations.
35+
* </p>
36+
*
37+
* @param <A>
38+
* The type of analysis module used, which must extend
39+
* {@link TmfStateSystemAnalysisModule}
40+
* @param <M>
41+
* The type of tree data model, which must implement
42+
* {@link ITmfTreeDataModel}
43+
*
44+
* @since 10.2
45+
*/
46+
public abstract class AbstractTreeBarChartDataProvider<A extends TmfStateSystemAnalysisModule, M extends ITmfTreeDataModel>
47+
extends AbstractTreeDataProvider<A, M> implements ITmfTreeBarChartDataProvider<M> {
48+
49+
/**
50+
* Constructor
51+
*
52+
* @param trace
53+
* The trace associated with this data provider
54+
* @param analysisModule
55+
* The analysis module used to compute data
56+
*/
57+
public AbstractTreeBarChartDataProvider(ITmfTrace trace, A analysisModule) {
58+
super(trace, analysisModule);
59+
}
60+
61+
@Override
62+
protected ITmfTreeModel<M> getTree(ITmfStateSystem ss, Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) throws StateSystemDisposedException {
63+
return new TmfTreeModelWithAxisDescriptors<>(getEntries(), getXAxisDescription(), getYAxisDescription(), getScope());
64+
}
65+
66+
/**
67+
* Get the entries specifying elements considered in the bar chart.
68+
*
69+
* @return The entries
70+
*/
71+
protected abstract List<M> getEntries();
72+
}

0 commit comments

Comments
 (0)