Search in sources :

Example 1 with IAnalysisModule

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

the class CriticalPathView method analysisStarted.

/**
 * Signal handler for analysis started, we need to rebuilt the entry list with
 * updated statistics values for the current graph worker of the critical path
 * module.
 *
 * @param signal
 *            The signal
 */
@TmfSignalHandler
public void analysisStarted(TmfStartAnalysisSignal signal) {
    IAnalysisModule analysis = signal.getAnalysisModule();
    if (analysis instanceof CriticalPathModule) {
        CriticalPathModule criticalPath = (CriticalPathModule) analysis;
        /*
             * We need to wait for CriticalPathDataProviderFactory to have
             * received this signal. Create a new phaser and register, and wait
             * for the end synch signal to arrive and advance in a new thread.
             */
        fPhaser = new Phaser();
        fPhaser.register();
        new Thread() {

            @Override
            public void run() {
                fPhaser.awaitAdvance(0);
                Collection<ITmfTrace> traces = TmfTraceManager.getTraceSetWithExperiment(getTrace());
                if (traces.contains(criticalPath.getTrace())) {
                    rebuild();
                }
            }
        }.start();
    }
}
Also used : CriticalPathModule(org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) Collection(java.util.Collection) Phaser(java.util.concurrent.Phaser) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 2 with IAnalysisModule

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

the class CpuUsageDataProviderTest method setUp.

/**
 * Setup the trace for the tests
 */
@Before
public void setUp() {
    IKernelTrace trace = new TmfXmlKernelTraceStub();
    IPath filePath = Activator.getAbsoluteFilePath(CPU_USAGE_FILE);
    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());
    }
    deleteSuppFiles(trace);
    ((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
    /*
         * FIXME: Make sure this analysis is finished before running the CPU analysis.
         * This block can be removed once analysis dependency and request precedence is
         * implemented
         */
    IAnalysisModule module = null;
    for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, TidAnalysisModule.class)) {
        module = mod;
    }
    assertNotNull(module);
    module.schedule();
    module.waitForCompletion();
    /* End of the FIXME block */
    module = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelCpuUsageAnalysis.class, KernelCpuUsageAnalysis.ID);
    assertNotNull(module);
    module.schedule();
    module.waitForCompletion();
    fDataProvider = CpuUsageDataProvider.create(trace);
    assertNotNull(fDataProvider);
    fTrace = 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) TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) KernelCpuUsageAnalysis(org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.KernelCpuUsageAnalysis) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) IKernelTrace(org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace) Before(org.junit.Before)

Example 3 with IAnalysisModule

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

the class CPUAnalysisBenchmark method initializeTrace.

private void initializeTrace(@NonNull String path, @NonNull LttngKernelTrace trace) throws TmfTraceException {
    trace.initTrace(null, path, CtfTmfEvent.class);
    trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null));
    IAnalysisModule module = trace.getAnalysisModule(TidAnalysisModule.ID);
    assertNotNull(module);
    module.schedule();
    assertTrue(module.waitForCompletion());
    // The data provider will use this module, so execute it
    module = trace.getAnalysisModule(KernelCpuUsageAnalysis.ID);
    assertNotNull(module);
    module.schedule();
    assertTrue(module.waitForCompletion());
}
Also used : IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal)

Example 4 with IAnalysisModule

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

the class LttngTraceAnalysisBenchmark method runAllBenchmarks.

/**
 * Runs all the benchmarks
 */
@Test
public void runAllBenchmarks() {
    Supplier<IAnalysisModule> moduleSupplier = () -> new KernelAnalysisModule();
    String directoryPath = "null";
    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 before " + "running this benchmark. See the javadoc of this class."));
        return;
    }
    File[] filesList = parentDirectory.listFiles();
    for (File file : filesList) {
        String path = file.getAbsolutePath() + "/kernel";
        CtfTmfTrace trace = new CtfTmfTrace();
        try {
            trace.initTrace(null, path, CtfTmfEvent.class);
        } catch (TmfTraceException e) {
            e.printStackTrace();
            break;
        }
        runOneBenchmark(trace, String.format(TEST_CPU, trace.toString()), cpu, Dimension.CPU_TIME, moduleSupplier);
        runOneBenchmark(trace, String.format(TEST_MEMORY, trace.toString()), memory, Dimension.USED_JAVA_HEAP, moduleSupplier);
        trace.dispose();
    }
}
Also used : IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) KernelAnalysisModule(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule) File(java.io.File) CtfTmfTrace(org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace) Test(org.junit.Test)

Example 5 with IAnalysisModule

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

the class LttngTraceAnalysisBenchmark method runOneBenchmark.

private static void runOneBenchmark(@NonNull CtfTmfTrace testTrace, String testName, runMethod method, Dimension dimension, Supplier<IAnalysisModule> moduleSupplier) {
    Performance perf = Performance.getDefault();
    PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName);
    perf.tagAsSummary(pm, "Trace Compass Analysis " + testName, dimension);
    for (int i = 0; i < LOOP_COUNT; i++) {
        LttngKernelTrace trace = null;
        IAnalysisModule module = null;
        String path = testTrace.getPath();
        try {
            trace = new LttngKernelTrace();
            module = moduleSupplier.get();
            module.setId("test");
            trace.initTrace(null, path, CtfTmfEvent.class);
            module.setTrace(trace);
            method.execute(pm, module);
            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();
}
Also used : IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) 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

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