use of org.eclipse.tracecompass.internal.analysis.profiling.core.callgraph.CallGraphAnalysis 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.internal.analysis.profiling.core.callgraph.CallGraphAnalysis 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.internal.analysis.profiling.core.callgraph.CallGraphAnalysis in project tracecompass by tracecompass.
the class FlameGraphView method buildFlameGraph.
/**
* Get the necessary data for the flame graph and display it
*
* @param callGraphProviders
* the callGraphAnalysis
*/
@VisibleForTesting
public void buildFlameGraph(Iterable<CallGraphAnalysis> callGraphProviders) {
/*
* Note for synchronization:
*
* Acquire the lock at entry. then we have 4 places to release it
*
* 1- if the lock failed
*
* 2- if the data is null and we have no UI to update
*
* 3- if the request is cancelled before it gets to the display
*
* 4- on a clean execution
*/
Job job = fJob;
if (job != null) {
job.cancel();
}
try {
fLock.acquire();
} catch (InterruptedException e) {
Activator.getDefault().logError(e.getMessage(), e);
fLock.release();
Thread.currentThread().interrupt();
}
if (!callGraphProviders.iterator().hasNext()) {
fTimeGraphViewer.setInput(null);
fLock.release();
return;
}
for (CallGraphAnalysis provider : callGraphProviders) {
provider.schedule();
}
job = new Job(Messages.CallGraphAnalysis_Execution) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
List<ThreadNode> input = new ArrayList<>();
for (CallGraphAnalysis callGraphAnalysis : callGraphProviders) {
callGraphAnalysis.waitForCompletion(monitor);
input.addAll(fContentPresentation == ContentPresentation.BY_THREAD ? callGraphAnalysis.getThreadNodes() : callGraphAnalysis.getFlameGraph());
}
// compute input outside of display thread.
Display.getDefault().asyncExec(() -> {
fTimeGraphViewer.setInput(input);
fTimeGraphViewer.resetStartFinishTime();
});
return Status.OK_STATUS;
} finally {
fJob = null;
fLock.release();
}
}
};
fJob = job;
job.schedule();
}
use of org.eclipse.tracecompass.internal.analysis.profiling.core.callgraph.CallGraphAnalysis 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.internal.analysis.profiling.core.callgraph.CallGraphAnalysis 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();
}
Aggregations