Search in sources :

Example 1 with ICallGraphProvider

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);
    }
}
Also used : CallStackAnalysisStub(org.eclipse.tracecompass.analysis.profiling.core.tests.stubs.CallStackAnalysisStub) ThreadNode(org.eclipse.tracecompass.internal.analysis.profiling.core.callgraph.ThreadNode) CallGraphAnalysis(org.eclipse.tracecompass.internal.analysis.profiling.core.callgraph.CallGraphAnalysis) ICallGraphProvider(org.eclipse.tracecompass.analysis.profiling.core.callgraph.ICallGraphProvider) AggregateData(org.eclipse.tracecompass.analysis.profiling.core.tests.data.CallStackTestData.AggregateData) Map(java.util.Map) Test(org.junit.Test)

Example 2 with ICallGraphProvider

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;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CallGraphAnalysis(org.eclipse.tracecompass.internal.analysis.profiling.core.callgraph.CallGraphAnalysis) ICallGraphProvider(org.eclipse.tracecompass.analysis.profiling.core.callgraph.ICallGraphProvider) Job(org.eclipse.core.runtime.jobs.Job) Nullable(org.eclipse.jdt.annotation.Nullable) CallStackAnalysis(org.eclipse.tracecompass.analysis.profiling.core.callstack.CallStackAnalysis) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 3 with ICallGraphProvider

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);
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) CallGraphAnalysis(org.eclipse.tracecompass.internal.analysis.profiling.core.callgraph.CallGraphAnalysis) ICallGraphProvider(org.eclipse.tracecompass.analysis.profiling.core.callgraph.ICallGraphProvider) ArrayList(java.util.ArrayList) CallStackAnalysis(org.eclipse.tracecompass.analysis.profiling.core.callstack.CallStackAnalysis) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 4 with ICallGraphProvider

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();
}
Also used : CallGraphAnalysis(org.eclipse.tracecompass.internal.analysis.profiling.core.callgraph.CallGraphAnalysis) ICallGraphProvider(org.eclipse.tracecompass.analysis.profiling.core.callgraph.ICallGraphProvider) TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) CtfTmfTrace(org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace) PerformanceMeter(org.eclipse.test.performance.PerformanceMeter) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) Performance(org.eclipse.test.performance.Performance) File(java.io.File) LttngUstCallStackAnalysis(org.eclipse.tracecompass.internal.lttng2.ust.core.callstack.LttngUstCallStackAnalysis) CallStackAnalysis(org.eclipse.tracecompass.analysis.profiling.core.callstack.CallStackAnalysis) Test(org.junit.Test)

Example 5 with ICallGraphProvider

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;
}
Also used : ICallGraphProvider(org.eclipse.tracecompass.analysis.profiling.core.callgraph.ICallGraphProvider) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) SegmentStoreStatisticsDataProvider(org.eclipse.tracecompass.internal.analysis.timing.core.segmentstore.SegmentStoreStatisticsDataProvider) CallStackAnalysis(org.eclipse.tracecompass.analysis.profiling.core.callstack.CallStackAnalysis) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

ICallGraphProvider (org.eclipse.tracecompass.analysis.profiling.core.callgraph.ICallGraphProvider)6 CallStackAnalysis (org.eclipse.tracecompass.analysis.profiling.core.callstack.CallStackAnalysis)5 CallGraphAnalysis (org.eclipse.tracecompass.internal.analysis.profiling.core.callgraph.CallGraphAnalysis)4 Nullable (org.eclipse.jdt.annotation.Nullable)2 Test (org.junit.Test)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 Performance (org.eclipse.test.performance.Performance)1 PerformanceMeter (org.eclipse.test.performance.PerformanceMeter)1 AggregateData (org.eclipse.tracecompass.analysis.profiling.core.tests.data.CallStackTestData.AggregateData)1 CallStackAnalysisStub (org.eclipse.tracecompass.analysis.profiling.core.tests.stubs.CallStackAnalysisStub)1 ThreadNode (org.eclipse.tracecompass.internal.analysis.profiling.core.callgraph.ThreadNode)1 SegmentStoreStatisticsDataProvider (org.eclipse.tracecompass.internal.analysis.timing.core.segmentstore.SegmentStoreStatisticsDataProvider)1 LttngUstCallStackAnalysis (org.eclipse.tracecompass.internal.lttng2.ust.core.callstack.LttngUstCallStackAnalysis)1 ISegment (org.eclipse.tracecompass.segmentstore.core.ISegment)1 TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)1 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)1