use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel in project tracecompass by tracecompass.
the class InputOutputDataProviderTest method testDiskActivity.
/**
* Test the data provider
*/
@Test
public void testDiskActivity() {
DisksIODataProvider provider = getProvider();
Collection<@NonNull DiskActivity> diskActivity = fTestCase.getDiskActivity();
for (DiskActivity test : diskActivity) {
Map<@NonNull String, @NonNull Object> parameters = test.getTimeQuery();
TmfModelResponse<@NonNull TmfTreeModel<@NonNull TmfTreeDataModel>> response = provider.fetchTree(parameters, PROGRESS_MONITOR);
assertEquals(ITmfResponse.Status.COMPLETED, response.getStatus());
TmfTreeModel<@NonNull TmfTreeDataModel> model = response.getModel();
assertNotNull(model);
parameters = test.getTimeQueryForModel(model);
TmfModelResponse<@NonNull ITmfXyModel> yResponse = provider.fetchXY(parameters, PROGRESS_MONITOR);
assertEquals(ITmfResponse.Status.COMPLETED, yResponse.getStatus());
ITmfXyModel yModel = yResponse.getModel();
assertNotNull(yModel);
Collection<@NonNull ISeriesModel> data = yModel.getSeriesData();
assertEquals(1, data.size());
ISeriesModel ySeries = data.iterator().next();
double[] expected = test.getActivity();
double[] actual = ySeries.getData();
for (int i = 0; i < expected.length; i++) {
assertTrue(String.format("No actual value at position %d for %s", i, test), actual.length > i);
assertEquals(String.format("Value at position %d for %s", i, test), expected[i], actual[i], 0.001);
}
assertEquals(String.format("More values than expected for %s", test), expected.length, actual.length);
}
}
use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel in project tracecompass by tracecompass.
the class CPUAnalysisBenchmark method benchmarkCPUModule.
@SuppressWarnings("restriction")
private static void benchmarkCPUModule(String testName, @NonNull LttngKernelTrace trace, int loopCount) throws TmfAnalysisException {
Performance perf = Performance.getDefault();
PerformanceMeter pmAnalysisExecution = perf.createPerformanceMeter(TEST_ID + testName + ": " + TEST_ANALYSIS_EXECUTION);
perf.tagAsSummary(pmAnalysisExecution, TEST_ANALYSIS_EXECUTION + '(' + testName + ')', Dimension.CPU_TIME);
PerformanceMeter pmQueryUsage = perf.createPerformanceMeter(TEST_ID + testName + ": " + TEST_ANALYSIS_QUERY);
perf.tagAsSummary(pmQueryUsage, TEST_ANALYSIS_QUERY + '(' + testName + ')', Dimension.CPU_TIME);
for (int i = 0; i < loopCount; i++) {
KernelCpuUsageAnalysis module = getModule(trace);
try {
pmAnalysisExecution.start();
TmfTestHelper.executeAnalysis(module);
pmAnalysisExecution.stop();
CpuUsageDataProvider dataProvider = CpuUsageDataProvider.create(trace);
assertNotNull(dataProvider);
// Query all CPU Usage for full time range, then 10 times 10%
// smaller ranges
int resolution = 1500;
long startTime = trace.getStartTime().toNanos();
long endTime = trace.getEndTime().toNanos();
pmQueryUsage.start();
for (int j = 0; j < 10; j++) {
// Query the tree for that range
TimeQueryFilter filter = new SelectedCpuQueryFilter(startTime, endTime, 2, Collections.emptyList(), Collections.emptySet());
@NonNull Map<@NonNull String, @NonNull Object> parameters = new HashMap<>();
parameters.put(DataProviderParameterUtils.REQUESTED_TIME_KEY, getTimeRequested(filter));
parameters.put(DataProviderParameterUtils.REQUESTED_ITEMS_KEY, Collections.emptyList());
parameters.put("cpus", Collections.emptySet());
TmfModelResponse<@NonNull TmfTreeModel<@NonNull CpuUsageEntryModel>> response = dataProvider.fetchTree(parameters, NULL_MONITOR);
TmfTreeModel<@NonNull CpuUsageEntryModel> model = response.getModel();
assertNotNull(model);
List<CpuUsageEntryModel> entries = model.getEntries();
assertNotNull(entries);
// Add all entries to the list of selected
List<Long> selected = new ArrayList<>();
for (CpuUsageEntryModel entry : entries) {
selected.add(entry.getId());
}
// Get the usage for all threads
filter = new SelectedCpuQueryFilter(startTime, endTime, resolution, selected, Collections.emptySet());
parameters = new HashMap<>();
parameters.put(DataProviderParameterUtils.REQUESTED_TIME_KEY, getTimeRequested(filter));
parameters.put(DataProviderParameterUtils.REQUESTED_ITEMS_KEY, selected);
parameters.put("cpus", Collections.emptySet());
TmfModelResponse<@NonNull ITmfXyModel> fetchXY = dataProvider.fetchXY(parameters, NULL_MONITOR);
ITmfXyModel model2 = fetchXY.getModel();
assertNotNull(model2);
// Reduce the time range
long step = (endTime - startTime) / 20;
startTime += step;
endTime -= step;
}
pmQueryUsage.stop();
} finally {
module.dispose();
}
}
pmAnalysisExecution.commit();
pmQueryUsage.commit();
}
use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel in project tracecompass by tracecompass.
the class XmlXyDataProviderTest method assertAndGetTree.
private static Map<Long, String> assertAndGetTree(ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> xyProvider, ITmfTrace trace, List<String> expectedStrings) {
TmfModelResponse<@NonNull TmfTreeModel<@NonNull ITmfTreeDataModel>> treeResponse = xyProvider.fetchTree(FetchParametersUtils.timeQueryToMap(new TimeQueryFilter(0, Long.MAX_VALUE, 2)), MONITOR);
assertNotNull(treeResponse);
assertEquals(ITmfResponse.Status.COMPLETED, treeResponse.getStatus());
TmfTreeModel<@NonNull ITmfTreeDataModel> treeModel = treeResponse.getModel();
assertNotNull(treeModel);
List<@NonNull ITmfTreeDataModel> treeEntries = treeModel.getEntries();
Map<Long, String> map = new HashMap<>();
for (int i = 0; i < expectedStrings.size(); i++) {
String expectedString = expectedStrings.get(i);
assertTrue("actual entry absent at " + i + ": " + expectedString, treeEntries.size() > i);
String[] split = expectedString.split(",");
ITmfTreeDataModel xmlXyEntry = treeEntries.get(i);
assertEquals("Checking entry name at " + i, split[0], xmlXyEntry.getName());
// Check the parent
long parentId = xmlXyEntry.getParentId();
if (parentId < 0) {
assertEquals("Checking empty parent at " + i, split[1], "null");
} else {
String parentName = map.get(parentId);
assertEquals("Checking parent at " + i, split[1], parentName);
}
map.put(xmlXyEntry.getId(), xmlXyEntry.getName());
}
assertEquals("Extra actual entries", expectedStrings.size(), treeEntries.size());
return map;
}
use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel in project tracecompass by tracecompass.
the class TmfTreeDataModelTest method testCompositeTree.
/**
* Test {@link TmfTreeCompositeDataProvider}
*/
@Test
public void testCompositeTree() {
List<DummyDataProvider> ddps = new ArrayList<>();
for (int i = 0; i < 3; i++) {
ddps.add(new DummyDataProvider(i));
}
TmfTreeCompositeDataProvider<@NonNull TmfTreeDataModel, @NonNull DummyDataProvider> composite = new TmfTreeCompositeDataProvider<>(ddps, "composite-dummy");
assertNotNull(composite);
NullProgressMonitor monitor = new NullProgressMonitor();
TmfModelResponse<@NonNull TmfTreeModel<@NonNull TmfTreeDataModel>> tree = composite.fetchTree(Collections.emptyMap(), monitor);
TmfTreeModel<@NonNull TmfTreeDataModel> model = tree.getModel();
assertNotNull(model);
assertEquals(Arrays.asList("header"), model.getHeaders());
assertEquals(3, model.getEntries().size());
// AnnotationCategories
TmfModelResponse<@NonNull AnnotationCategoriesModel> returnVal = composite.fetchAnnotationCategories(Collections.emptyMap(), monitor);
AnnotationCategoriesModel categoryModel = returnVal.getModel();
assertNotNull(categoryModel);
assertEquals(Arrays.asList("common", "0", "1", "2"), categoryModel.getAnnotationCategories());
// Annotations
TmfModelResponse<@NonNull AnnotationModel> annotations = composite.fetchAnnotations(Collections.emptyMap(), monitor);
AnnotationModel annotationsModel = annotations.getModel();
assertNotNull(annotationsModel);
Collection<@NonNull Annotation> collection = annotationsModel.getAnnotations().get("test");
assertNotNull(collection);
assertEquals(6, collection.size());
}
use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel in project tracecompass by tracecompass.
the class HistogramDataProvider method fetchTree.
@Override
public TmfModelResponse<TmfTreeModel<TmfTreeDataModel>> fetchTree(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
if (fCached != null) {
return fCached;
}
fModule.waitForInitialization();
Builder<TmfTreeDataModel> builder = ImmutableList.builder();
builder.add(new TmfTreeDataModel(fTraceId, -1, Collections.singletonList(getTrace().getName())));
builder.add(new TmfTreeDataModel(fTotalId, fTraceId, Collections.singletonList(Objects.requireNonNull(Messages.HistogramDataProvider_Total))));
ITmfStateSystem eventsSs = Objects.requireNonNull(fModule.getStateSystem(TmfStatisticsEventTypesModule.ID));
if (eventsSs.optQuarkAbsolute(Attributes.LOST_EVENTS) != ITmfStateSystem.INVALID_ATTRIBUTE) {
builder.add(new TmfTreeDataModel(fLostId, fTraceId, Collections.singletonList(Objects.requireNonNull(Messages.HistogramDataProvider_Lost))));
}
if (eventsSs.waitUntilBuilt(0)) {
TmfModelResponse<TmfTreeModel<TmfTreeDataModel>> response = new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), builder.build()), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
fCached = response;
return response;
}
return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), builder.build()), ITmfResponse.Status.RUNNING, CommonStatusMessage.RUNNING);
}
Aggregations