use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.
the class CriticalPathModule method executeAnalysis.
@Override
protected boolean executeAnalysis(final IProgressMonitor monitor) throws TmfAnalysisException {
/* Get the worker id */
Object workerObj = getParameter(PARAM_WORKER);
if (workerObj == null) {
return false;
}
if (!(workerObj instanceof IGraphWorker)) {
// $NON-NLS-1$
throw new IllegalStateException("Worker parameter must be an IGraphWorker");
}
IGraphWorker worker = (IGraphWorker) workerObj;
/* Get the graph */
TmfGraphBuilderModule graphModule = fGraphModule;
graphModule.schedule();
monitor.setTaskName(NLS.bind(Messages.CriticalPathModule_waitingForGraph, graphModule.getName()));
if (!graphModule.waitForCompletion(monitor)) {
// $NON-NLS-1$
Activator.getInstance().logInfo("Critical path execution: graph building was cancelled. Results may not be accurate.");
return false;
}
TmfGraph graph = graphModule.getGraph();
if (graph == null) {
// $NON-NLS-1$//$NON-NLS-2$
throw new TmfAnalysisException("Critical Path analysis: graph " + graphModule.getName() + " is null");
}
TmfVertex head = graph.getHead(worker);
if (head == null) {
/* Nothing happens with this worker, return an empty graph */
fCriticalPath = new TmfGraph();
return true;
}
ICriticalPathAlgorithm cp = getAlgorithm(graph);
try {
fCriticalPath = cp.compute(head, null);
return true;
} catch (CriticalPathAlgorithmException e) {
Activator.getInstance().logError(NonNullUtils.nullToEmptyString(e.getMessage()), e);
}
return false;
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.
the class CtfTmfLostEventStatisticsTest method setUp.
// ------------------------------------------------------------------------
// Maintenance
// ------------------------------------------------------------------------
/**
* Test setup
*/
@BeforeClass
public static void setUp() {
ITmfTrace trace = CtfTmfTestTraceUtils.getTrace(lostEventsTrace);
fTrace = trace;
/* Prepare the two analysis-backed state systems */
fTotalsMod = new TmfStatisticsTotalsModule();
fEventTypesMod = new TmfStatisticsEventTypesModule();
try {
fTotalsMod.setTrace(trace);
fEventTypesMod.setTrace(trace);
} catch (TmfAnalysisException e) {
fail();
}
fTotalsMod.schedule();
fEventTypesMod.schedule();
assertTrue(fTotalsMod.waitForCompletion());
assertTrue(fEventTypesMod.waitForCompletion());
ITmfStateSystem totalsSS = fTotalsMod.getStateSystem();
ITmfStateSystem eventTypesSS = fEventTypesMod.getStateSystem();
assertNotNull(totalsSS);
assertNotNull(eventTypesSS);
fStats = new TmfStateStatistics(totalsSS, eventTypesSS);
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.
the class StatisticsAnalysisBenchmark method runTest.
private static void runTest(CtfTestTrace testTrace, String testName, Map<String, Long> testCases) {
Performance perf = Performance.getDefault();
PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + '#' + testName);
perf.tagAsSummary(pm, "Statistics Analysis: " + testName, Dimension.CPU_TIME);
if (testTrace == CtfTestTrace.DJANGO_CLIENT || testTrace == CtfTestTrace.DJANGO_HTTPD) {
/* Do not show all traces in the global summary */
perf.tagAsGlobalSummary(pm, "Statistics Analysis: " + testName, Dimension.CPU_TIME);
}
for (int i = 0; i < LOOP_COUNT; i++) {
LttngKernelTrace trace = null;
TmfStatisticsModule module = null;
try {
trace = new LttngKernelTrace();
module = new TmfStatisticsModule();
module.setId("test");
// TODO Allow the utility method to return a LttngKernelTrace directly
CtfTmfTrace ctfTmfTrace = CtfTmfTestTraceUtils.getTrace(testTrace);
trace.initTrace(null, ctfTmfTrace.getPath(), CtfTmfEvent.class);
module.setTrace(trace);
pm.start();
TmfTestHelper.executeAnalysis(module);
pm.stop();
ITmfStatistics stats = module.getStatistics();
if (stats == null) {
throw new IllegalStateException();
}
Map<String, Long> map = stats.getEventTypesTotal();
/*
* Test each of the entries
*/
try {
for (Entry<String, Long> entry : testCases.entrySet()) {
Long value = map.get(entry.getKey());
assertNotNull(value);
assertTrue(value.equals(entry.getValue()));
}
} catch (NullPointerException e) {
fail(e.getMessage());
}
/*
* Delete the supplementary files, so that the next iteration
* rebuilds the state system.
*/
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();
CtfTmfTestTraceUtils.dispose(testTrace);
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.
the class CPUAnalysisBenchmark method getModule.
private static KernelCpuUsageAnalysis getModule(@NonNull LttngKernelTrace trace) throws TmfAnalysisException {
KernelCpuUsageAnalysis module = new KernelCpuUsageAnalysis();
try {
/* Initialize the analysis module */
module.setId("test");
module.setTrace(trace);
return module;
} catch (TmfAnalysisException e) {
module.dispose();
throw e;
}
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.
the class KernelExecutionGraphBenchmark method runOneBenchmark.
private void runOneBenchmark(String testName, RunMethod method, Dimension dimension, int loopCount) {
Performance perf = Performance.getDefault();
PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName);
PerformanceMeter pmCritPath = perf.createPerformanceMeter(CRIT_PATH_TEST_ID + testName);
perf.tagAsSummary(pm, "Execution graph " + testName, dimension);
for (int i = 0; i < loopCount; i++) {
LttngKernelTrace trace = null;
OsExecutionGraph module = null;
try {
trace = new LttngKernelTrace();
module = new OsExecutionGraph();
module.setId("test");
trace.initTrace(null, fFileTracePath, CtfTmfEvent.class);
module.setTrace(trace);
method.execute(pm, module);
// If a thread is specified, benchmark the critical path
if (fThreadId > 0) {
benchmarkCriticalPath(testName, method, pmCritPath, trace, module);
}
/*
* Delete the supplementary files, so that the next iteration
* rebuilds the state system.
*/
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();
pmCritPath.commit();
}
Aggregations