Search in sources :

Example 1 with SegmentStoreStatisticsModel

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());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SegmentStoreStatisticsModel(org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsModel) HashMap(java.util.HashMap) NonNull(org.eclipse.jdt.annotation.NonNull) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) ITableColumnDescriptor(org.eclipse.tracecompass.tmf.core.model.ITableColumnDescriptor) Test(org.junit.Test)

Example 2 with SegmentStoreStatisticsModel

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());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SegmentStoreStatisticsModel(org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsModel) HashMap(java.util.HashMap) NonNull(org.eclipse.jdt.annotation.NonNull) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) ITableColumnDescriptor(org.eclipse.tracecompass.tmf.core.model.ITableColumnDescriptor) Test(org.junit.Test)

Example 3 with SegmentStoreStatisticsModel

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());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SegmentStoreStatisticsModel(org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsModel) FilterTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.FilterTimeQueryFilter) NonNull(org.eclipse.jdt.annotation.NonNull) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) ITableColumnDescriptor(org.eclipse.tracecompass.tmf.core.model.ITableColumnDescriptor) Test(org.junit.Test)

Example 4 with SegmentStoreStatisticsModel

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());
    }
}
Also used : SegmentStoreStatisticsModel(org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsModel)

Example 5 with SegmentStoreStatisticsModel

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);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SegmentStoreStatisticsModel(org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsModel) ArrayList(java.util.ArrayList) IStatistics(org.eclipse.tracecompass.analysis.timing.core.statistics.IStatistics) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) FilterTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.FilterTimeQueryFilter) TimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter)

Aggregations

SegmentStoreStatisticsModel (org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsModel)7 TmfTreeModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 NonNull (org.eclipse.jdt.annotation.NonNull)3 ITableColumnDescriptor (org.eclipse.tracecompass.tmf.core.model.ITableColumnDescriptor)3 FilterTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.FilterTimeQueryFilter)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 ArrayList (java.util.ArrayList)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 Action (org.eclipse.jface.action.Action)1 IAction (org.eclipse.jface.action.IAction)1 AbstractSegmentStatisticsAnalysis (org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.AbstractSegmentStatisticsAnalysis)1 IStatistics (org.eclipse.tracecompass.analysis.timing.core.statistics.IStatistics)1 ISegment (org.eclipse.tracecompass.segmentstore.core.ISegment)1 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)1 TmfAbstractAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule)1 TimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter)1 ITmfTreeDataProvider (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataProvider)1