Search in sources :

Example 1 with TmfAnalysisException

use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.

the class CriticalPathModule method executeAnalysis.

@Override
protected boolean executeAnalysis(final IProgressMonitor monitor) throws TmfAnalysisException {
    /* Get the worker id */
    Object workerObj = getParameter(PARAM_WORKER);
    if (workerObj == null) {
        return false;
    }
    if (!(workerObj instanceof IGraphWorker)) {
        // $NON-NLS-1$
        throw new IllegalStateException("Worker parameter must be an IGraphWorker");
    }
    IGraphWorker worker = (IGraphWorker) workerObj;
    /* Get the graph */
    TmfGraphBuilderModule graphModule = fGraphModule;
    graphModule.schedule();
    monitor.setTaskName(NLS.bind(Messages.CriticalPathModule_waitingForGraph, graphModule.getName()));
    if (!graphModule.waitForCompletion(monitor)) {
        // $NON-NLS-1$
        Activator.getInstance().logInfo("Critical path execution: graph building was cancelled.  Results may not be accurate.");
        return false;
    }
    TmfGraph graph = graphModule.getGraph();
    if (graph == null) {
        // $NON-NLS-1$//$NON-NLS-2$
        throw new TmfAnalysisException("Critical Path analysis: graph " + graphModule.getName() + " is null");
    }
    TmfVertex head = graph.getHead(worker);
    if (head == null) {
        /* Nothing happens with this worker, return an empty graph */
        fCriticalPath = new TmfGraph();
        return true;
    }
    ICriticalPathAlgorithm cp = getAlgorithm(graph);
    try {
        fCriticalPath = cp.compute(head, null);
        return true;
    } catch (CriticalPathAlgorithmException e) {
        Activator.getInstance().logError(NonNullUtils.nullToEmptyString(e.getMessage()), e);
    }
    return false;
}
Also used : TmfVertex(org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex) TmfGraph(org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) IGraphWorker(org.eclipse.tracecompass.analysis.graph.core.base.IGraphWorker) TmfGraphBuilderModule(org.eclipse.tracecompass.analysis.graph.core.building.TmfGraphBuilderModule)

Example 2 with TmfAnalysisException

use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.

the class CtfTmfLostEventStatisticsTest method setUp.

// ------------------------------------------------------------------------
// Maintenance
// ------------------------------------------------------------------------
/**
 * Test setup
 */
@BeforeClass
public static void setUp() {
    ITmfTrace trace = CtfTmfTestTraceUtils.getTrace(lostEventsTrace);
    fTrace = trace;
    /* Prepare the two analysis-backed state systems */
    fTotalsMod = new TmfStatisticsTotalsModule();
    fEventTypesMod = new TmfStatisticsEventTypesModule();
    try {
        fTotalsMod.setTrace(trace);
        fEventTypesMod.setTrace(trace);
    } catch (TmfAnalysisException e) {
        fail();
    }
    fTotalsMod.schedule();
    fEventTypesMod.schedule();
    assertTrue(fTotalsMod.waitForCompletion());
    assertTrue(fEventTypesMod.waitForCompletion());
    ITmfStateSystem totalsSS = fTotalsMod.getStateSystem();
    ITmfStateSystem eventTypesSS = fEventTypesMod.getStateSystem();
    assertNotNull(totalsSS);
    assertNotNull(eventTypesSS);
    fStats = new TmfStateStatistics(totalsSS, eventTypesSS);
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfStatisticsTotalsModule(org.eclipse.tracecompass.tmf.core.statistics.TmfStatisticsTotalsModule) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) TmfStateStatistics(org.eclipse.tracecompass.tmf.core.statistics.TmfStateStatistics) TmfStatisticsEventTypesModule(org.eclipse.tracecompass.tmf.core.statistics.TmfStatisticsEventTypesModule) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) BeforeClass(org.junit.BeforeClass)

Example 3 with TmfAnalysisException

use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.

the class StatisticsAnalysisBenchmark method runTest.

private static void runTest(CtfTestTrace testTrace, String testName, Map<String, Long> testCases) {
    Performance perf = Performance.getDefault();
    PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + '#' + testName);
    perf.tagAsSummary(pm, "Statistics Analysis: " + testName, Dimension.CPU_TIME);
    if (testTrace == CtfTestTrace.DJANGO_CLIENT || testTrace == CtfTestTrace.DJANGO_HTTPD) {
        /* Do not show all traces in the global summary */
        perf.tagAsGlobalSummary(pm, "Statistics Analysis: " + testName, Dimension.CPU_TIME);
    }
    for (int i = 0; i < LOOP_COUNT; i++) {
        LttngKernelTrace trace = null;
        TmfStatisticsModule module = null;
        try {
            trace = new LttngKernelTrace();
            module = new TmfStatisticsModule();
            module.setId("test");
            // TODO Allow the utility method to return a LttngKernelTrace directly
            CtfTmfTrace ctfTmfTrace = CtfTmfTestTraceUtils.getTrace(testTrace);
            trace.initTrace(null, ctfTmfTrace.getPath(), CtfTmfEvent.class);
            module.setTrace(trace);
            pm.start();
            TmfTestHelper.executeAnalysis(module);
            pm.stop();
            ITmfStatistics stats = module.getStatistics();
            if (stats == null) {
                throw new IllegalStateException();
            }
            Map<String, Long> map = stats.getEventTypesTotal();
            /*
                 * Test each of the entries
                 */
            try {
                for (Entry<String, Long> entry : testCases.entrySet()) {
                    Long value = map.get(entry.getKey());
                    assertNotNull(value);
                    assertTrue(value.equals(entry.getValue()));
                }
            } catch (NullPointerException e) {
                fail(e.getMessage());
            }
            /*
                 * 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();
            }
        } catch (TmfAnalysisException | TmfTraceException e) {
            fail(e.getMessage());
        } finally {
            if (module != null) {
                module.dispose();
            }
            if (trace != null) {
                trace.dispose();
            }
        }
    }
    pm.commit();
    CtfTmfTestTraceUtils.dispose(testTrace);
}
Also used : LttngKernelTrace(org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace) TmfStatisticsModule(org.eclipse.tracecompass.tmf.core.statistics.TmfStatisticsModule) ITmfStatistics(org.eclipse.tracecompass.tmf.core.statistics.ITmfStatistics) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) PerformanceMeter(org.eclipse.test.performance.PerformanceMeter) Performance(org.eclipse.test.performance.Performance) File(java.io.File) CtfTmfTrace(org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace)

Example 4 with TmfAnalysisException

use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.

the class CPUAnalysisBenchmark method getModule.

private static KernelCpuUsageAnalysis getModule(@NonNull LttngKernelTrace trace) throws TmfAnalysisException {
    KernelCpuUsageAnalysis module = new KernelCpuUsageAnalysis();
    try {
        /* Initialize the analysis module */
        module.setId("test");
        module.setTrace(trace);
        return module;
    } catch (TmfAnalysisException e) {
        module.dispose();
        throw e;
    }
}
Also used : TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) KernelCpuUsageAnalysis(org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.KernelCpuUsageAnalysis)

Example 5 with TmfAnalysisException

use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.

the class KernelExecutionGraphBenchmark method runOneBenchmark.

private void runOneBenchmark(String testName, RunMethod method, Dimension dimension, int loopCount) {
    Performance perf = Performance.getDefault();
    PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName);
    PerformanceMeter pmCritPath = perf.createPerformanceMeter(CRIT_PATH_TEST_ID + testName);
    perf.tagAsSummary(pm, "Execution graph " + testName, dimension);
    for (int i = 0; i < loopCount; i++) {
        LttngKernelTrace trace = null;
        OsExecutionGraph module = null;
        try {
            trace = new LttngKernelTrace();
            module = new OsExecutionGraph();
            module.setId("test");
            trace.initTrace(null, fFileTracePath, CtfTmfEvent.class);
            module.setTrace(trace);
            method.execute(pm, module);
            // If a thread is specified, benchmark the critical path
            if (fThreadId > 0) {
                benchmarkCriticalPath(testName, method, pmCritPath, trace, module);
            }
            /*
                 * 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();
            }
        } catch (TmfAnalysisException | TmfTraceException e) {
            fail(e.getMessage());
        } finally {
            if (module != null) {
                module.dispose();
            }
            if (trace != null) {
                trace.dispose();
            }
        }
    }
    pm.commit();
    pmCritPath.commit();
}
Also used : TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) OsExecutionGraph(org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsExecutionGraph) PerformanceMeter(org.eclipse.test.performance.PerformanceMeter) LttngKernelTrace(org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace) Performance(org.eclipse.test.performance.Performance) File(java.io.File)

Aggregations

TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)44 Test (org.junit.Test)21 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)15 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)14 TestAnalysis (org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis)9 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)8 TmfTraceException (org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException)8 File (java.io.File)7 LttngKernelTrace (org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace)6 IStatus (org.eclipse.core.runtime.IStatus)5 Performance (org.eclipse.test.performance.Performance)5 PerformanceMeter (org.eclipse.test.performance.PerformanceMeter)5 BeforeClass (org.junit.BeforeClass)5 CtfTmfTrace (org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace)4 Nullable (org.eclipse.jdt.annotation.Nullable)3 DataDrivenAnalysisModule (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule)3 XmlUtilsTest (org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest)3 IAnalysisModuleHelper (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2