Search in sources :

Example 41 with TmfExperiment

use of org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment in project tracecompass by tracecompass.

the class DistributedCriticalPathTest method setUpExperiment.

/**
 * Setup the experiment for the tests
 *
 * @param traceFiles
 *            File names relative to this plugin for the trace files to load
 * @return The experiment with its graph module executed
 * @throws TmfTraceException
 */
private ITmfTrace setUpExperiment(String... traceFiles) throws TmfTraceException {
    ITmfTrace[] traces = new ITmfTrace[traceFiles.length];
    int i = 0;
    for (String traceFile : traceFiles) {
        TmfXmlKernelTraceStub trace = new TmfXmlKernelTraceStub();
        IPath filePath = Activator.getAbsoluteFilePath(traceFile);
        IStatus status = trace.validate(null, filePath.toOSString());
        if (!status.isOK()) {
            fail(status.getException().getMessage());
        }
        trace.initTrace(null, filePath.toOSString(), ITmfEvent.class);
        traces[i++] = trace;
    }
    TmfExperiment experiment = new TmfExperiment(ITmfEvent.class, EXPERIMENT, traces, BLOCK_SIZE, null);
    experiment.traceOpened(new TmfTraceOpenedSignal(this, experiment, null));
    IAnalysisModule module = null;
    for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(experiment, TmfGraphBuilderModule.class)) {
        module = mod;
    }
    assertNotNull(module);
    module.schedule();
    assertTrue(module.waitForCompletion());
    return experiment;
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IStatus(org.eclipse.core.runtime.IStatus) TmfXmlKernelTraceStub(org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.TmfXmlKernelTraceStub) IPath(org.eclipse.core.runtime.IPath) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal)

Example 42 with TmfExperiment

use of org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment in project tracecompass by tracecompass.

the class LttngExperimentIndexingBenchmark method testIndexing.

/**
 * Tests experiment indexing from the parent directory containing the traces
 * whose path is given as an input.
 *
 * @param directoryPath
 *            Path to the directory containing the group of traces
 * @param loopCount
 *            Number of iterations
 */
public static void testIndexing(String directoryPath, int loopCount) {
    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 " + "LttngExperimentIndexingBenchmark 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) + " traces";
    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];
        int i = 0;
        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;
            }
            traces[i] = trace;
            i++;
        }
        TmfExperiment experiment = new TmfExperiment(CtfTmfEvent.class, "Test experiment", traces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
        pm.start();
        experiment.indexTrace(true);
        pm.stop();
        experiment.dispose();
    }
    pm.commit();
}
Also used : TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) 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 43 with TmfExperiment

use of org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment in project tracecompass by tracecompass.

the class TraceSynchronizationBenchmark method testSmallTraces.

/**
 * Run the benchmark with 2 small traces
 */
@Test
public void testSmallTraces() {
    CtfTmfTrace trace1 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_SRC);
    CtfTmfTrace trace2 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_DEST);
    ITmfTrace[] traces = { trace1, trace2 };
    TmfExperiment experiment = new TmfExperiment(CtfTmfEvent.class, "Test experiment", traces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
    runCpuTest(experiment, "Match TCP events", 40);
    trace1.dispose();
    trace2.dispose();
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) CtfTmfTrace(org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace) Test(org.junit.Test)

Example 44 with TmfExperiment

use of org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment in project tracecompass by tracecompass.

the class TmfExperimentUtilsTest method testGetModuleById.

/**
 * Test the
 * {@link TmfExperimentUtils#getAnalysisModuleForHost(TmfExperiment, String, String)}
 * method
 */
@Test
public void testGetModuleById() {
    String commonModule = AnalysisManagerTest.MODULE_PARAM;
    String notCommonModule = AnalysisManagerTest.MODULE_SECOND;
    String host1 = TmfTestTrace.A_TEST_10K.getPath();
    String host2 = TmfTestTrace.A_TEST_10K2.getPath();
    TmfExperiment experiment = fExperiment;
    assertNotNull(experiment);
    /* First module for trace 1 */
    IAnalysisModule module = TmfExperimentUtils.getAnalysisModuleForHost(experiment, host1, commonModule);
    assertNotNull(module);
    IAnalysisModule traceModule = fTraces[0].getAnalysisModule(commonModule);
    assertNotNull(traceModule);
    assertEquals(module, traceModule);
    /* Second inexistent module for trace 1 */
    assertNull(TmfExperimentUtils.getAnalysisModuleForHost(experiment, host1, notCommonModule));
    traceModule = fTraces[0].getAnalysisModule(notCommonModule);
    assertNull(traceModule);
    /* First module for trace 2 */
    module = TmfExperimentUtils.getAnalysisModuleForHost(experiment, host2, commonModule);
    assertNotNull(module);
    traceModule = fTraces[1].getAnalysisModule(commonModule);
    assertNotNull(traceModule);
    assertEquals(module, traceModule);
    /* Second module for trace 2 */
    module = TmfExperimentUtils.getAnalysisModuleForHost(experiment, host2, notCommonModule);
    assertNotNull(module);
    traceModule = fTraces[1].getAnalysisModule(notCommonModule);
    assertNotNull(traceModule);
    assertEquals(module, traceModule);
}
Also used : TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) Test(org.junit.Test)

Example 45 with TmfExperiment

use of org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment in project tracecompass by tracecompass.

the class TmfExperimentTest method testGetAnalysisModules.

// ------------------------------------------------------------------------
// State system, statistics and modules methods
// ------------------------------------------------------------------------
@Test
public void testGetAnalysisModules() {
    TmfExperiment experiment = fExperiment;
    assertNotNull(experiment);
    /* There should not be any modules at this point */
    Iterable<IAnalysisModule> modules = experiment.getAnalysisModules();
    assertFalse(modules.iterator().hasNext());
    /* Open the experiment, the modules should be populated */
    experiment.traceOpened(new TmfTraceOpenedSignal(this, experiment, null));
    modules = experiment.getAnalysisModules();
    Iterable<TestExperimentAnalysis> testModules = TmfTraceUtils.getAnalysisModulesOfClass(experiment, TestExperimentAnalysis.class);
    assertTrue(modules.iterator().hasNext());
    assertTrue(testModules.iterator().hasNext());
    /*
         * Test that a module that applies to one of its trace is present in an
         * experiment
         */
    ITmfTrace trace1 = TmfTestTrace.A_TEST_10K.getTrace();
    ITmfTrace trace2 = TmfTestTrace.A_TEST_10K2.getTrace();
    ITmfTrace trace3 = TmfTestTrace.A_TEST_10K2.getTraceAsStub2();
    /*
         * Create an experiment with TmfTraceStub, the module other should not
         * be there
         */
    ITmfTrace[] tracesExp1 = { trace1, trace2 };
    TmfExperiment exp1 = new TmfExperiment(tracesExp1[0].getEventType(), "Experiment 1", tracesExp1, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
    /*
         * Create an experiment containing some TmfTraceStub2, the module other
         * should be present
         */
    ITmfTrace[] tracesExp2 = { trace1, trace3 };
    TmfExperiment exp2 = new TmfExperiment(tracesExp2[0].getEventType(), "Experiment 1", tracesExp2, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
    try {
        /* Open the experiment, the modules should be populated */
        exp1.traceOpened(new TmfTraceOpenedSignal(this, exp1, null));
        assertNull(exp1.getAnalysisModule(AnalysisManagerTest.MODULE_SECOND));
        /* Open the experiment, the modules should be populated */
        exp2.traceOpened(new TmfTraceOpenedSignal(this, exp2, null));
        assertNotNull(exp2.getAnalysisModule(AnalysisManagerTest.MODULE_SECOND));
    } finally {
        trace1.dispose();
        trace2.dispose();
        trace3.dispose();
        exp1.dispose();
        exp2.dispose();
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) TestExperimentAnalysis(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestExperimentAnalysis) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) Test(org.junit.Test)

Aggregations

TmfExperiment (org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment)55 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)33 Test (org.junit.Test)31 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)11 TmfTraceOpenedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal)9 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)8 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)7 AnalysisManagerTest (org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest)7 CtfTmfTrace (org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace)7 Nullable (org.eclipse.jdt.annotation.Nullable)5 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)4 NonNull (org.eclipse.jdt.annotation.NonNull)3 KernelAnalysisModule (org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule)3 TmfTraceClosedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal)3 TmfTraceSelectedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal)3 ITmfTimestampTransform (org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform)3 SynchronizationAlgorithm (org.eclipse.tracecompass.tmf.core.synchronization.SynchronizationAlgorithm)3 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)3 CtfTmfEvent (org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent)3 Before (org.junit.Before)3