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();
}
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();
}
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();
}
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;
}
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);
}
Aggregations