Search in sources :

Example 1 with TmfExperiment

use of org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment 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 2 with TmfExperiment

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

the class TraceSynchronizationBenchmark method testDjangoTraces.

/**
 * Run the benchmark with 3 bigger traces
 */
@Test
public void testDjangoTraces() {
    CtfTmfTrace trace1 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.DJANGO_CLIENT);
    CtfTmfTrace trace2 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.DJANGO_DB);
    CtfTmfTrace trace3 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.DJANGO_HTTPD);
    ITmfTrace[] traces = { trace1, trace2, trace3 };
    TmfExperiment experiment = new TmfExperiment(CtfTmfEvent.class, "Test experiment", traces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
    runCpuTest(experiment, "Django traces", 10);
    runMemoryTest(experiment, "Django traces", 10);
    trace1.dispose();
    trace2.dispose();
    trace3.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 3 with TmfExperiment

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

the class ExperimentSyncTest method testDjangoExperimentSync.

/**
 * Testing synchronization with 3 traces, one of which synchronizes with
 * both other
 */
@Test
public void testDjangoExperimentSync() {
    CtfTmfTrace trace1 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.DJANGO_CLIENT);
    CtfTmfTrace trace2 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.DJANGO_DB);
    CtfTmfTrace trace3 = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.DJANGO_HTTPD);
    ITmfTrace[] traces = { trace1, trace2, trace3 };
    TmfExperiment experiment = new TmfExperiment(traces[0].getEventType(), EXPERIMENT, traces, BLOCK_SIZE, null);
    SynchronizationAlgorithm syncAlgo = experiment.synchronizeTraces(true);
    ITmfTimestampTransform tt1 = syncAlgo.getTimestampTransform(trace1);
    ITmfTimestampTransform tt2 = syncAlgo.getTimestampTransform(trace2);
    ITmfTimestampTransform tt3 = syncAlgo.getTimestampTransform(trace3);
    trace1.setTimestampTransform(tt1);
    trace2.setTimestampTransform(tt2);
    trace3.setTimestampTransform(tt3);
    assertEquals(TimestampTransformFactory.getDefaultTransform(), tt1);
    assertEquals("TmfTimestampTransformLinearFast [ slope = 0.9999996313017589597204633828681240, offset = 498490309972.0038068817738527724192 ]", tt2.toString());
    assertEquals("TmfTimestampTransformLinearFast [ slope = 1.000000119014882262265342419815932, offset = -166652893534.6189900382736187431134 ]", tt3.toString());
    experiment.dispose();
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) ITmfTimestampTransform(org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform) CtfTmfTrace(org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace) SynchronizationAlgorithm(org.eclipse.tracecompass.tmf.core.synchronization.SynchronizationAlgorithm) Test(org.junit.Test)

Example 4 with TmfExperiment

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

the class UstKernelSyncTest method setup.

/**
 * Test setup
 */
@Before
public void setup() {
    ITmfTrace ustTrace = CtfTmfTestTraceUtils.getTrace(UST_TRACE);
    ITmfTrace kernelTrace = LttngKernelTestTraceUtils.getTrace(KERNEL_TRACE);
    TmfExperiment experiment = new TmfExperiment(CtfTmfEvent.class, "test-exp", new ITmfTrace[] { ustTrace, kernelTrace }, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
    /* Simulate experiment being opened */
    TmfSignalManager.dispatchSignal(new TmfTraceOpenedSignal(this, experiment, null));
    TmfSignalManager.dispatchSignal(new TmfTraceSelectedSignal(this, experiment));
    KernelAnalysisModule module = TmfTraceUtils.getAnalysisModuleOfClass(experiment, KernelAnalysisModule.class, KernelAnalysisModule.ID);
    assertNotNull(module);
    module.waitForCompletion();
    fExperiment = experiment;
    fUstTrace = ustTrace;
    fKernelModule = module;
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) TmfTraceSelectedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) KernelAnalysisModule(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule) Before(org.junit.Before)

Example 5 with TmfExperiment

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

the class UstKernelSyncTest method testWholeUstTrace.

/**
 * Test going through the whole UST trace, making sure the VTID context of
 * each event corresponds to the TID given by the kernel analysis at the
 * same timestamp.
 */
@Test
public void testWholeUstTrace() {
    TmfExperiment experiment = fExperiment;
    ITmfTrace ustTrace = fUstTrace;
    KernelAnalysisModule module = fKernelModule;
    assertNotNull(experiment);
    assertNotNull(ustTrace);
    assertNotNull(module);
    ITmfContext context = ustTrace.seekEvent(0L);
    CtfTmfEvent ustEvent = (CtfTmfEvent) ustTrace.getNext(context);
    int count = 0;
    while (ustEvent != null) {
        Long ustVtid = ustEvent.getContent().getFieldValue(Long.class, "context._vtid");
        /* All events in the trace should have that context */
        assertNotNull(ustVtid);
        long ts = ustEvent.getTimestamp().toNanos();
        long cpu = ustEvent.getCPU();
        Integer kernelTid = KernelThreadInformationProvider.getThreadOnCpu(module, cpu, ts);
        assertNotNull(kernelTid);
        assertEquals("Wrong TID for trace event " + ustEvent.toString(), ustVtid.longValue(), kernelTid.longValue());
        ustEvent = (CtfTmfEvent) ustTrace.getNext(context);
        count++;
    }
    /* Make sure we've read all expected events */
    assertEquals(UST_TRACE.getNbEvents(), count);
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) KernelAnalysisModule(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule) 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