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