use of org.eclipse.tracecompass.analysis.profiling.core.callgraph.ICallGraphProvider in project tracecompass by tracecompass.
the class CallGraphWithCallStackAnalysisTest method testCallGraph.
/**
* Test the callgraph with the expected
*/
@Test
public void testCallGraph() {
CallStackAnalysisStub cga = getModule();
ICallGraphProvider cg = cga.getCallGraph();
assertTrue(cg instanceof CallGraphAnalysis);
CallGraphAnalysis callgraph = (CallGraphAnalysis) cg;
callgraph.schedule();
assertTrue(callgraph.waitForCompletion());
List<@NonNull ThreadNode> threadNodes = callgraph.getThreadNodes();
assertFalse(threadNodes.isEmpty());
Map<Integer, Map<String, AggregateData>> expected = getTraceData().getExpectedCallGraph();
assertEquals("Number of threads", expected.size(), threadNodes.size());
for (ThreadNode threadNode : threadNodes) {
Map<String, AggregateData> expectedCg = expected.get((int) threadNode.getId());
assertNotNull(expectedCg);
compareCallGraphs(expectedCg, threadNode.getChildren(), 0);
}
}
use of org.eclipse.tracecompass.analysis.profiling.core.callgraph.ICallGraphProvider in project tracecompass by tracecompass.
the class CallGraphTableViewer method getSegmentStoreProvider.
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
@Override
@Nullable
protected ISegmentStoreProvider getSegmentStoreProvider(@NonNull ITmfTrace trace) {
Iterable<CallStackAnalysis> csModules = TmfTraceUtils.getAnalysisModulesOfClass(trace, CallStackAnalysis.class);
@Nullable CallStackAnalysis csModule = Iterables.getFirst(csModules, null);
if (csModule == null) {
return null;
}
csModule.schedule();
ICallGraphProvider cgModule = csModule.getCallGraph();
if (!(cgModule instanceof CallGraphAnalysis)) {
return null;
}
CallGraphAnalysis module = (CallGraphAnalysis) cgModule;
Job job = new Job(Messages.CallGraphAnalysis) {
@Override
protected IStatus run(IProgressMonitor monitor) {
// The callgraph module will be scheduled by the callstack analysis, but we need
// to wait for its specific termination
module.waitForCompletion(Objects.requireNonNull((monitor)));
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
};
job.schedule();
return csModule;
}
use of org.eclipse.tracecompass.analysis.profiling.core.callgraph.ICallGraphProvider in project tracecompass by tracecompass.
the class FlameGraphView method traceSelected.
/**
* Handler for the trace selected signal
*
* @param signal
* The incoming signal
*/
@TmfSignalHandler
public void traceSelected(final TmfTraceSelectedSignal signal) {
ITmfTrace trace = signal.getTrace();
fTrace = trace;
if (trace != null) {
Iterable<CallStackAnalysis> csModules = TmfTraceUtils.getAnalysisModulesOfClass(trace, CallStackAnalysis.class);
List<CallGraphAnalysis> cgModules = new ArrayList<>();
for (CallStackAnalysis csModule : csModules) {
csModule.schedule();
ICallGraphProvider cgModule = csModule.getCallGraph();
if (cgModule instanceof CallGraphAnalysis) {
cgModules.add((CallGraphAnalysis) cgModule);
}
}
fFlamegraphModules = cgModules;
buildFlameGraph(cgModules);
}
}
use of org.eclipse.tracecompass.analysis.profiling.core.callgraph.ICallGraphProvider in project tracecompass by tracecompass.
the class CallStackAndGraphBenchmark method runCpuBenchmark.
/**
* Run benchmark for the trace
*
* @throws TmfTraceException
* Exceptions thrown getting the trace
*/
@Test
public void runCpuBenchmark() throws TmfTraceException {
Performance perf = Performance.getDefault();
PerformanceMeter callStackBuildPm = Objects.requireNonNull(perf.createPerformanceMeter(TEST_ID + String.format(TEST_CALLSTACK_BUILD, fName)));
perf.tagAsSummary(callStackBuildPm, String.format(TEST_CALLSTACK_BUILD, fName), Dimension.CPU_TIME);
PerformanceMeter callStackSegStorePm = Objects.requireNonNull(perf.createPerformanceMeter(TEST_ID + String.format(TEST_CALLSTACK_PARSESEGSTORE, fName)));
perf.tagAsSummary(callStackSegStorePm, String.format(TEST_CALLSTACK_PARSESEGSTORE, fName), Dimension.CPU_TIME);
PerformanceMeter callgraphBuildPm = Objects.requireNonNull(perf.createPerformanceMeter(TEST_ID + String.format(TEST_CALLGRAPH_BUILD, fName)));
perf.tagAsSummary(callgraphBuildPm, String.format(TEST_CALLGRAPH_BUILD, fName), Dimension.CPU_TIME);
for (int i = 0; i < fLoopCount; i++) {
TmfTrace trace = null;
try {
trace = getTrace();
trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null));
CallStackAnalysis callStackModule = TmfTraceUtils.getAnalysisModuleOfClass(trace, CallStackAnalysis.class, LttngUstCallStackAnalysis.ID);
assertNotNull(callStackModule);
callStackModule.triggerAutomatically(false);
// Benchmark the call stack analysis
callStackBuildPm.start();
TmfTestHelper.executeAnalysis(callStackModule);
callStackBuildPm.stop();
// Benchmark the segment store iteration
ISegmentStore<@NonNull ISegment> segmentStore = callStackModule.getSegmentStore();
assertNotNull(segmentStore);
callStackSegStorePm.start();
// Iterate through the whole segment store
Iterator<ISegment> iterator = segmentStore.iterator();
while (iterator.hasNext()) {
iterator.next();
}
callStackSegStorePm.stop();
ICallGraphProvider callGraphModule = callStackModule.getCallGraph();
assertTrue(callGraphModule instanceof CallGraphAnalysis);
// Benchmark the call graph analysis
callgraphBuildPm.start();
TmfTestHelper.executeAnalysis((CallGraphAnalysis) callGraphModule);
callgraphBuildPm.stop();
/*
* Delete the supplementary files, so that the next iteration rebuilds the state
* system.
*/
File suppDir = new File(TmfTraceManager.getSupplementaryFileDir(trace));
for (File file : suppDir.listFiles()) {
file.delete();
}
} finally {
if (trace != null) {
trace.dispose();
}
}
}
callStackBuildPm.commit();
callgraphBuildPm.commit();
}
use of org.eclipse.tracecompass.analysis.profiling.core.callgraph.ICallGraphProvider in project tracecompass by tracecompass.
the class CallGraphStatisticsDataProviderFactory method createProvider.
@Override
@Nullable
public ITmfTreeDataProvider<? extends ITmfTreeDataModel> createProvider(ITmfTrace trace) {
if (trace instanceof TmfExperiment) {
return TmfTreeCompositeDataProvider.create(TmfTraceManager.getTraceSet(trace), ID);
}
Iterator<CallStackAnalysis> csModules = TmfTraceUtils.getAnalysisModulesOfClass(trace, CallStackAnalysis.class).iterator();
if (!csModules.hasNext()) {
return null;
}
CallStackAnalysis csModule = csModules.next();
csModule.schedule();
ICallGraphProvider cgModule = csModule.getCallGraph();
if (!(cgModule instanceof CallGraphAnalysis)) {
return null;
}
CallGraphStatisticsAnalysis statisticsAnalysis = new CallGraphStatisticsAnalysis();
try {
statisticsAnalysis.setTrace(trace);
} catch (TmfAnalysisException e) {
statisticsAnalysis.dispose();
return null;
}
statisticsAnalysis.schedule();
SegmentStoreStatisticsDataProvider dp = new SegmentStoreStatisticsDataProvider(trace, statisticsAnalysis, CallGraphStatisticsAnalysis.ID);
SymbolFormatter fe = new SymbolFormatter(trace);
dp.setLabelMapper(fe);
return dp;
}
Aggregations