use of org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsModel in project tracecompass by tracecompass.
the class SegmentStoreStatisticsDataProviderTest method testFetchTreeWithMapperFullRange.
/**
* Test to verify
* {@link SegmentStoreStatisticsDataProvider#fetchTree(Map, org.eclipse.core.runtime.IProgressMonitor)}
* for the full trace
*/
@Test
public void testFetchTreeWithMapperFullRange() {
Map<@NonNull String, @NonNull Object> fetchParameters = new HashMap<>();
TmfModelResponse<@NonNull TmfTreeModel<@NonNull SegmentStoreStatisticsModel>> response = fTestDataProvider2.fetchTree(fetchParameters, new NullProgressMonitor());
assertNotNull(response);
TmfTreeModel<@NonNull SegmentStoreStatisticsModel> treeModel = response.getModel();
assertNotNull(treeModel);
assertEquals("Header list size", EXPECTED_HEADER_LIST.size(), treeModel.getHeaders().size());
assertEquals("Header list", EXPECTED_HEADER_LIST, treeModel.getHeaders());
List<@NonNull ITableColumnDescriptor> columnDescriptors = treeModel.getColumnDescriptors();
assertEquals("Header descriptor list size", EXPECTED_HEADER_LIST.size(), columnDescriptors.size());
assertEquals("Column descriptor list", fExpectedDescriptors, columnDescriptors);
assertNull("Scope", treeModel.getScope());
List<@NonNull SegmentStoreStatisticsModel> entries = treeModel.getEntries();
assertNotNull("Entries", entries);
verifyEntries(LIST_OF_EXPECTED_LABELS_WITH_MAPPER_FULL, EXPECTED_STATS_WITH_MAPPER_FULL, entries, 0, EXPECTED_STATS_WITH_MAPPER_FULL.size());
}
use of org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsModel in project tracecompass by tracecompass.
the class SegmentStoreStatisticsDataProviderTest method testFetchTreeFullRange.
// ------------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------------
/**
* Test to verify
* {@link SegmentStoreStatisticsDataProvider#fetchTree(Map, org.eclipse.core.runtime.IProgressMonitor)}
* for the full trace
*/
@Test
public void testFetchTreeFullRange() {
Map<@NonNull String, @NonNull Object> fetchParameters = new HashMap<>();
TmfModelResponse<@NonNull TmfTreeModel<@NonNull SegmentStoreStatisticsModel>> response = fTestDataProvider.fetchTree(fetchParameters, new NullProgressMonitor());
assertNotNull(response);
TmfTreeModel<@NonNull SegmentStoreStatisticsModel> treeModel = response.getModel();
assertNotNull(treeModel);
assertEquals("Header list size", EXPECTED_HEADER_LIST.size(), treeModel.getHeaders().size());
assertEquals("Header list", EXPECTED_HEADER_LIST, treeModel.getHeaders());
List<@NonNull ITableColumnDescriptor> columnDescriptors = treeModel.getColumnDescriptors();
assertEquals("Header descriptor list size", EXPECTED_HEADER_LIST.size(), columnDescriptors.size());
assertEquals("Column descriptor list", fExpectedDescriptors, columnDescriptors);
assertNull("Scope", treeModel.getScope());
List<@NonNull SegmentStoreStatisticsModel> entries = treeModel.getEntries();
assertNotNull("Entries", entries);
verifyEntries(LIST_OF_EXPECTED_LABELS_FULL, EXPECTED_STATS_FULL, entries, 0, EXPECTED_STATS_FULL.size());
}
use of org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsModel in project tracecompass by tracecompass.
the class SegmentStoreStatisticsDataProviderTest method testFetchTreeSpecificRange.
/**
* Test to verify
* {@link SegmentStoreStatisticsDataProvider#fetchTree(Map, org.eclipse.core.runtime.IProgressMonitor)}
* for a specific time range
*/
@Test
public void testFetchTreeSpecificRange() {
long start = 1024;
long end = 4096;
FilterTimeQueryFilter filter = new FilterTimeQueryFilter(start, end, 2, true);
Map<@NonNull String, @NonNull Object> fetchParameters = FetchParametersUtils.filteredTimeQueryToMap(filter);
TmfModelResponse<@NonNull TmfTreeModel<@NonNull SegmentStoreStatisticsModel>> response = fTestDataProvider.fetchTree(fetchParameters, new NullProgressMonitor());
assertNotNull(response);
TmfTreeModel<@NonNull SegmentStoreStatisticsModel> treeModel = response.getModel();
assertNotNull(treeModel);
assertEquals("Header list size", EXPECTED_HEADER_LIST.size(), treeModel.getHeaders().size());
assertEquals("Header list", EXPECTED_HEADER_LIST, treeModel.getHeaders());
List<@NonNull ITableColumnDescriptor> columnDescriptors = treeModel.getColumnDescriptors();
assertEquals("Header descriptor list size", EXPECTED_HEADER_LIST.size(), columnDescriptors.size());
assertEquals("Column descriptor list", fExpectedDescriptors, columnDescriptors);
assertNull("Scope", treeModel.getScope());
List<@NonNull SegmentStoreStatisticsModel> entries = treeModel.getEntries();
assertNotNull("Entries", entries);
verifyEntries(LIST_OF_EXPECTED_LABELS_FULL, EXPECTED_STATS_FULL, entries, 0, EXPECTED_STATS_FULL.size() + EXPECTED_STATS_SELECTION.size());
verifyEntries(LIST_OF_EXPECTED_LABELS_SELECTION, EXPECTED_STATS_SELECTION, entries, LIST_OF_EXPECTED_LABELS_FULL.size(), EXPECTED_STATS_FULL.size() + EXPECTED_STATS_SELECTION.size());
}
use of org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsModel in project tracecompass by tracecompass.
the class SegmentStoreStatisticsDataProviderTest method verifyEntries.
private static void verifyEntries(List<@NonNull List<@NonNull String>> expectedLabels, @NonNull List<@NonNull StatisticsHolder> expectedEntries, List<@NonNull SegmentStoreStatisticsModel> entries, int startIndex, int nbEntries) {
assertEquals("Number of entries", nbEntries, entries.size());
for (int i = 0; i < expectedLabels.size(); i++) {
int index = startIndex + i;
SegmentStoreStatisticsModel entry = entries.get(index);
assertEquals("Entry (index " + index + ")", expectedLabels.get(i), entry.getLabels());
assertEquals("name (index " + index + ")", expectedEntries.get(i).fName, entry.getName());
assertEquals("id (index " + index + ")", expectedEntries.get(i).fId, entry.getId());
assertEquals("parentId (index " + index + ")", expectedEntries.get(i).fParentId, entry.getParentId());
assertEquals("min (index " + index + ")", expectedEntries.get(i).fMin, entry.getMin());
assertEquals("max (index " + index + ")", expectedEntries.get(i).fMax, entry.getMax());
assertEquals("Average (index " + index + ")", expectedEntries.get(i).fAverage, entry.getMean(), 0.02);
assertEquals("StdDev (index " + index + ")", expectedEntries.get(i).fStdDev, entry.getStdDev(), 0.02);
assertEquals("Count (index " + index + ")", expectedEntries.get(i).fNbElements, entry.getNbElements());
assertEquals("Total (index " + index + ")", expectedEntries.get(i).fTotal, entry.getTotal(), 0.02);
assertEquals("Min start (index " + index + ")", expectedEntries.get(i).fMinStart, entry.getMinStart());
assertEquals("Min end (index " + index + ")", expectedEntries.get(i).fMinEnd, entry.getMinEnd());
assertEquals("Max start (index " + index + ")", expectedEntries.get(i).fMaxStart, entry.getMaxStart());
assertEquals("Max end (index " + index + ")", expectedEntries.get(i).fMaxEnd, entry.getMaxEnd());
}
}
use of org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsModel in project tracecompass by tracecompass.
the class SegmentStoreStatisticsDataProvider method fetchTree.
@Override
public TmfModelResponse<TmfTreeModel<SegmentStoreStatisticsModel>> fetchTree(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
IAnalysisModule module = fModule;
if (module != null) {
if (monitor != null) {
module.waitForCompletion(monitor);
if (monitor.isCanceled()) {
return new TmfModelResponse<>(null, Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
}
} else {
module.waitForCompletion();
}
}
IStatistics<ISegment> statsTotal = fProvider.getStatsTotal();
if (statsTotal == null) {
return new TmfModelResponse<>(null, Status.FAILED, CommonStatusMessage.ANALYSIS_INITIALIZATION_FAILED);
}
List<SegmentStoreStatisticsModel> list = new ArrayList<>();
String rootName = getRootEntryName();
if (rootName == null) {
rootName = getTrace().getName();
}
list.add(new SegmentStoreStatisticsModel(fTraceId, -1, getCellLabels(NonNullUtils.nullToEmptyString(rootName), statsTotal), statsTotal));
/*
* Add statistics for full duration.
*/
long totalId = getUniqueId(TOTAL_PREFIX);
list.add(new SegmentStoreStatisticsModel(totalId, fTraceId, getCellLabels(Objects.requireNonNull(Messages.SegmentStoreStatisticsDataProvider_Total), statsTotal), statsTotal));
Map<String, IStatistics<ISegment>> totalStats = fProvider.getStatsPerType();
for (Entry<String, IStatistics<ISegment>> entry : totalStats.entrySet()) {
IStatistics<ISegment> statistics = entry.getValue();
list.add(new SegmentStoreStatisticsModel(getUniqueId(TOTAL_PREFIX + entry.getKey()), totalId, getCellLabels(entry.getKey(), statistics), statistics));
}
/*
* Add statistics for selection if any.
*/
TimeQueryFilter filter = FetchParametersUtils.createTimeQuery(fetchParameters);
Boolean isFiltered = DataProviderParameterUtils.extractIsFiltered(fetchParameters);
if (filter != null && isFiltered != null && isFiltered) {
long start = filter.getStart();
long end = filter.getEnd();
IProgressMonitor nonNullMonitor = monitor != null ? monitor : new NullProgressMonitor();
IStatistics<ISegment> statsForRange = fProvider.getStatsForRange(start, end, nonNullMonitor);
if (statsForRange == null) {
return new TmfModelResponse<>(null, Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
}
long selectionId = getUniqueId(SELECTION_PREFIX);
if (statsForRange.getNbElements() > 0) {
list.add(new SegmentStoreStatisticsModel(selectionId, fTraceId, getCellLabels(Objects.requireNonNull(Messages.SegmentStoreStatisticsDataProvider_Selection), statsForRange), statsForRange));
Map<String, IStatistics<ISegment>> selectionStats = fProvider.getStatsPerTypeForRange(start, end, nonNullMonitor);
for (Entry<String, IStatistics<ISegment>> entry : selectionStats.entrySet()) {
IStatistics<ISegment> statistics = entry.getValue();
list.add(new SegmentStoreStatisticsModel(getUniqueId(SELECTION_PREFIX + entry.getKey()), selectionId, getCellLabels(entry.getKey(), statistics), statistics));
}
}
}
TmfTreeModel.Builder<SegmentStoreStatisticsModel> treeModelBuilder = new TmfTreeModel.Builder();
treeModelBuilder.setColumnDescriptors(getColumnDescriptors());
treeModelBuilder.setEntries(Collections.unmodifiableList(list));
return new TmfModelResponse<>(treeModelBuilder.build(), Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
Aggregations