Search in sources :

Example 6 with IAnalysisModule

use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.

the class LttngExperimentAnalysisBenchmark method testExperiment.

/**
 * Tests an experiment (group of traces) with an analysis module
 * (OsExecutionGraph() in this example)
 *
 * @param directoryPath
 *            Path to the directory containing the group of traces
 * @param loopCount
 *            Number of iterations
 * @param moduleSupplier
 *            Parameter specifying which analysis module we want to test
 * @param isExperiment
 *            Boolean parameter to specify whether the analysis module is
 *            for an experiment (like the OsExecutionGraph module) or for a
 *            trace (like KernelAnalysisModule)
 * @throws TmfTraceException
 * @throws TmfAnalysisException
 */
private static void testExperiment(String directoryPath, int loopCount, Supplier<IAnalysisModule> moduleSupplier, boolean isExperiment) throws TmfTraceException, TmfAnalysisException {
    File parentDirectory = new File(directoryPath);
    if (!parentDirectory.isDirectory() || parentDirectory.list() == null) {
        System.err.println(String.format("Trace directory not found !\nYou need to setup the directory path for the LttngExperimentAnalysisBenchmar class." + " See the javadoc of this class."));
        return;
    }
    // List of all files and directories
    File[] filesList = parentDirectory.listFiles();
    int size = filesList.length;
    String testName = "Experiment of" + Integer.toString(size);
    Performance perf = Performance.getDefault();
    PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName + CPU);
    perf.tagAsSummary(pm, TEST_SUMMARY + ':' + testName + CPU, Dimension.CPU_TIME);
    for (int j = 0; j < loopCount; j++) {
        CtfTmfTrace[] traces = new CtfTmfTrace[size];
        IAnalysisModule[] modules = new IAnalysisModule[size];
        int i = 0;
        for (File file : filesList) {
            String path = file.getAbsolutePath() + "/kernel";
            CtfTmfTrace trace = new CtfTmfTrace();
            try {
                trace.initTrace(null, path, CtfTmfEvent.class);
            } finally {
            }
            traces[i] = trace;
            if (!isExperiment) {
                try {
                    IAnalysisModule module = null;
                    module = moduleSupplier.get();
                    module.setId("test");
                    try {
                        module.setTrace(trace);
                    } finally {
                    }
                    modules[i] = module;
                } finally {
                }
            }
            i++;
        }
        TmfExperiment experiment = new TmfExperiment(CtfTmfEvent.class, "Test experiment", traces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
        IAnalysisModule module = null;
        if (isExperiment) {
            try {
                module = moduleSupplier.get();
                module.setId("test");
                try {
                    module.setTrace(experiment);
                } finally {
                }
            } finally {
            }
            pm.start();
            module.schedule();
            module.waitForCompletion();
            pm.stop();
            module.dispose();
        } else {
            pm.start();
            for (IAnalysisModule mod : modules) {
                mod.schedule();
            }
            for (IAnalysisModule mod : modules) {
                mod.waitForCompletion();
            }
            pm.stop();
            for (IAnalysisModule mod : modules) {
                mod.dispose();
            }
        }
        experiment.dispose();
    }
    pm.commit();
}
Also used : TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) 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 7 with IAnalysisModule

use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.

the class LttngExecutionGraphTest method setUpTrace.

/**
 * Setup the trace for the tests
 *
 * @param traceFile
 *            File name relative to this plugin for the trace file to load
 * @return The trace with its graph module executed
 */
public ITmfTrace setUpTrace(String traceFile) {
    TmfXmlKernelTraceStub trace = new TmfXmlKernelTraceStub();
    IPath filePath = Activator.getAbsoluteFilePath(traceFile);
    IStatus status = trace.validate(null, filePath.toOSString());
    if (!status.isOK()) {
        fail(status.getException().getMessage());
    }
    try {
        trace.initTrace(null, filePath.toOSString(), TmfEvent.class);
    } catch (TmfTraceException e) {
        fail(e.getMessage());
    }
    trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null));
    IAnalysisModule module = null;
    for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, TmfGraphBuilderModule.class)) {
        module = mod;
    }
    assertNotNull(module);
    module.schedule();
    module.waitForCompletion();
    return trace;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) TmfXmlKernelTraceStub(org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.TmfXmlKernelTraceStub) IPath(org.eclipse.core.runtime.IPath) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal)

Example 8 with IAnalysisModule

use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.

the class CriticalPathParameterProvider method getParameter.

@Override
public Object getParameter(String name) {
    if (name.equals(CriticalPathModule.PARAM_WORKER)) {
        final HostThread currentHostThread = fCurrentHostThread;
        if (currentHostThread == null) {
            return null;
        }
        /* Try to find the worker for the critical path */
        IAnalysisModule mod = getModule();
        if (mod instanceof CriticalPathModule) {
            // $NON-NLS-1$
            OsWorker worker = new OsWorker(currentHostThread, "", 0);
            return worker;
        }
    }
    return null;
}
Also used : HostThread(org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread) OsWorker(org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsWorker) CriticalPathModule(org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)

Example 9 with IAnalysisModule

use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.

the class LttngUstResponseBenchmark method beforeRunningTest.

@Override
protected void beforeRunningTest(ITmfTrace trace) {
    List<IAnalysisModule> modules = new ArrayList<>(3);
    modules.add(trace.getAnalysisModule(LttngUstCallStackAnalysis.ID));
    for (IAnalysisModule module : modules) {
        if (module != null) {
            module.schedule();
        }
    }
    for (IAnalysisModule module : modules) {
        if (module != null) {
            assertTrue(module.waitForCompletion());
        }
    }
}
Also used : IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) ArrayList(java.util.ArrayList)

Example 10 with IAnalysisModule

use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.

the class XmlXyDataProviderTest method runModule.

private static void runModule(ITmfTrace trace) {
    IAnalysisModule module = trace.getAnalysisModule(ANALYSIS_ID);
    assertNotNull(module);
    module.schedule();
    assertTrue(module.waitForCompletion());
}
Also used : IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)

Aggregations

IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)71 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)28 Test (org.junit.Test)18 TmfTraceOpenedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal)17 TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)15 ArrayList (java.util.ArrayList)12 ISegmentStoreProvider (org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider)11 HashSet (java.util.HashSet)10 Nullable (org.eclipse.jdt.annotation.Nullable)9 TmfTraceException (org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException)8 TmfTrace (org.eclipse.tracecompass.tmf.core.trace.TmfTrace)7 TmfExperiment (org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment)7 TestAnalysis (org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis)7 File (java.io.File)6 IStatus (org.eclipse.core.runtime.IStatus)6 ISegment (org.eclipse.tracecompass.segmentstore.core.ISegment)6 Before (org.junit.Before)6 IPath (org.eclipse.core.runtime.IPath)5 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)5 HashMap (java.util.HashMap)4