Search in sources :

Example 11 with ISegment

use of org.eclipse.tracecompass.segmentstore.core.ISegment in project tracecompass by tracecompass.

the class AbstractStatsAnalysisTest method testPartialStats.

/**
 * Test the partial statistics
 *
 * @throws TmfAnalysisException
 *             should not happen
 */
@Test
public void testPartialStats() throws TmfAnalysisException {
    TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
    StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
    IStatistics<@NonNull ISegment> totalStats = fixture.getStatsForRange(100, 1100, new NullProgressMonitor());
    assertNotNull(totalStats);
    // no need to test the content much as it is tested in the other test.
    // 1051 = 1001 where start is between start and end + 50 overlapping
    // start
    assertEquals(1051, totalStats.getNbElements());
    trace.dispose();
    fixture.dispose();
}
Also used : TmfXmlTraceStubNs(org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) TmfXmlTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) Test(org.junit.Test)

Example 12 with ISegment

use of org.eclipse.tracecompass.segmentstore.core.ISegment in project tracecompass by tracecompass.

the class AbstractSegmentStoreAnalysisModule method executeAnalysis.

@Override
protected boolean executeAnalysis(IProgressMonitor monitor) throws TmfAnalysisException {
    SegmentStoreType type = getSegmentStoreType();
    ISegmentStore<ISegment> store = null;
    switch(type) {
        case Distinct:
        // Fall-through
        case Fast:
        // Fall-through
        case Stable:
            store = buildInMemorySegmentStore(type, monitor);
            break;
        case OnDisk:
            @Nullable final String dataFileName = getDataFileName();
            store = buildOnDiskSegmentStore(dataFileName, monitor);
            break;
        default:
            // $NON-NLS-1$
            Activator.getInstance().logError("Unknown segment store type: " + type);
            break;
    }
    if (store == null) {
        return false;
    }
    fSegmentStore = store;
    sendUpdate(store);
    return true;
}
Also used : SegmentStoreType(org.eclipse.tracecompass.segmentstore.core.SegmentStoreFactory.SegmentStoreType) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 13 with ISegment

use of org.eclipse.tracecompass.segmentstore.core.ISegment in project tracecompass by tracecompass.

the class AbstractSegmentStatisticsAnalysis method calculateTotalPerType.

private Map<@NonNull String, IStatistics<@NonNull ISegment>> calculateTotalPerType(Iterable<ISegment> segments, IProgressMonitor monitor) {
    Map<String, IStatistics<ISegment>> perSegmentTypeStats = new HashMap<>();
    for (ISegment segment : segments) {
        if (monitor.isCanceled()) {
            return Collections.emptyMap();
        }
        String segmentType = getSegmentType(segment);
        if (segmentType != null) {
            IStatistics<ISegment> values = perSegmentTypeStats.getOrDefault(segmentType, new Statistics<>(getMapper()));
            values.update(segment);
            perSegmentTypeStats.put(segmentType, values);
        }
    }
    return perSegmentTypeStats;
}
Also used : HashMap(java.util.HashMap) IStatistics(org.eclipse.tracecompass.analysis.timing.core.statistics.IStatistics) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment)

Example 14 with ISegment

use of org.eclipse.tracecompass.segmentstore.core.ISegment in project tracecompass by tracecompass.

the class AbstractSegmentStatisticsAnalysis method getSegmentStore.

/**
 * Get the segment store from which we want the statistics
 *
 * @return The segment store
 */
@Nullable
private Iterable<@NonNull ISegment> getSegmentStore(long start, long end) {
    ISegmentStoreProvider segmentStoreProviderModule = fSegmentStoreProviderModule;
    if (segmentStoreProviderModule == null) {
        return null;
    }
    if (segmentStoreProviderModule instanceof IAnalysisModule) {
        ((IAnalysisModule) segmentStoreProviderModule).waitForCompletion();
    }
    long t0 = Long.min(start, end);
    long t1 = Long.max(start, end);
    ISegmentStore<@NonNull ISegment> segmentStore = segmentStoreProviderModule.getSegmentStore();
    return segmentStore != null ? isEternity(t0, t1) ? segmentStore : segmentStore.getIntersectingElements(t0, t1) : Collections.emptyList();
}
Also used : ISegmentStoreProvider(org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 15 with ISegment

use of org.eclipse.tracecompass.segmentstore.core.ISegment 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

ISegment (org.eclipse.tracecompass.segmentstore.core.ISegment)51 Test (org.junit.Test)22 NonNull (org.eclipse.jdt.annotation.NonNull)7 Nullable (org.eclipse.jdt.annotation.Nullable)7 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)7 ISegmentStoreProvider (org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)6 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)5 Map (java.util.Map)4 Predicate (java.util.function.Predicate)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 IStatistics (org.eclipse.tracecompass.analysis.timing.core.statistics.IStatistics)4 BasicSegment (org.eclipse.tracecompass.segmentstore.core.BasicSegment)4 ISegmentStore (org.eclipse.tracecompass.segmentstore.core.ISegmentStore)4 Objects (java.util.Objects)3 TableViewer (org.eclipse.jface.viewers.TableViewer)3 Performance (org.eclipse.test.performance.Performance)3 PerformanceMeter (org.eclipse.test.performance.PerformanceMeter)3