use of org.eclipse.tracecompass.tmf.core.statistics.TmfStatisticsModule 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.statistics.TmfStatisticsModule in project tracecompass by tracecompass.
the class HistogramDataProviderTest method testHelloLost.
/**
* Test the {@link HistogramDataProvider} with the
* {@link CtfTestTrace#HELLO_LOST} trace. Ensure that the expected tree and xy
* models are returned
*
* @throws TmfAnalysisException
* if the trace is set more that once
*/
@Test
public void testHelloLost() throws TmfAnalysisException {
CtfTmfTrace trace = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.HELLO_LOST);
TmfStatisticsModule module = new TmfStatisticsModule();
module.setName("Statistics");
assertTrue("Statistics Analysis should apply to this trace", module.setTrace(trace));
assertEquals("Statistics Analysis shouls be schedulable", Status.OK_STATUS, module.schedule());
assertTrue("Statistics Analysis should run successfully", module.waitForCompletion());
try {
HistogramDataProvider provider = new HistogramDataProvider(trace, module);
TmfModelResponse<@NonNull TmfTreeModel<@NonNull TmfTreeDataModel>> treeResponse = provider.fetchTree(FetchParametersUtils.timeQueryToMap(new TimeQueryFilter(START, END, 2)), null);
assertEquals("Response Status should be COMPLETED, as we waited for the analysis to complete", ITmfResponse.Status.COMPLETED, treeResponse.getStatus());
TmfTreeModel<@NonNull TmfTreeDataModel> treeModel = treeResponse.getModel();
assertNotNull(treeModel);
assertEquals(EXPECTED_FULL_PATHS, getFullPaths(treeModel.getEntries()));
List<Long> ids = Lists.transform(treeModel.getEntries(), TmfTreeDataModel::getId);
SelectionTimeQueryFilter selectionFilter = new SelectionTimeQueryFilter(START, END, 100, ids);
TmfModelResponse<@NonNull ITmfXyModel> xyResponse = provider.fetchXY(FetchParametersUtils.selectionTimeQueryToMap(selectionFilter), null);
assertEquals("Response Status should be COMPLETED, as we waited for the analysis to complete", ITmfResponse.Status.COMPLETED, xyResponse.getStatus());
ITmfXyModel xyModel = xyResponse.getModel();
assertNotNull(xyModel);
assertEquals(EXPECTED_YDATA, Maps.uniqueIndex(xyModel.getSeriesData(), ISeriesModel::getId));
} finally {
module.dispose();
CtfTmfTestTraceUtils.dispose(CtfTestTrace.HELLO_LOST);
}
}
use of org.eclipse.tracecompass.tmf.core.statistics.TmfStatisticsModule in project tracecompass by tracecompass.
the class TmfStatisticsViewer method buildStatisticsTree.
/**
* Requests all the data of the trace to the state system which contains
* information about the statistics.
*
* Since the viewer may be listening to multiple traces, it may receive an
* experiment rather than a single trace. The filtering is done with the
* method {@link #isListeningTo(String trace)}.
*
* @param trace
* The trace for which a request must be done
* @param timeRange
* The time range that will be requested to the state system
* @param isGlobal
* Tells if the request is for the global event count or the
* partial one.
*/
private void buildStatisticsTree(final ITmfTrace trace, final TmfTimeRange timeRange, final boolean isGlobal) {
final TmfStatisticsTree statsData = TmfStatisticsTreeManager.getStatTree(getTreeID());
if (statsData == null) {
return;
}
Map<ITmfTrace, Job> updateJobs;
if (isGlobal) {
updateJobs = fUpdateJobsGlobal;
} else {
updateJobs = fUpdateJobsPartial;
}
for (ITmfTrace aTrace : TmfTraceManager.getTraceSet(trace)) {
if (!isListeningTo(aTrace)) {
continue;
}
/* Retrieve the statistics object */
final TmfStatisticsModule statsMod = TmfTraceUtils.getAnalysisModuleOfClass(aTrace, TmfStatisticsModule.class, TmfStatisticsModule.ID);
if (statsMod == null) {
/* No statistics module available for this trace */
continue;
}
updateJobs.computeIfAbsent(aTrace, k -> {
// $NON-NLS-1$
Job job = new StatisticsUpdateJob("Statistics update", aTrace, isGlobal, timeRange, statsMod, this);
job.setSystem(true);
job.schedule();
return job;
});
}
}
Aggregations