Search in sources :

Example 6 with ISegment

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

the class IOStateSystemSegmentStore method getIntersectingElements.

@Override
@NonNull
public Iterable<@NonNull ISegment> getIntersectingElements(long start, long end) {
    long startTime = Math.max(start, fStateSystem.getStartTime());
    long endTime = Math.min(end, fStateSystem.getCurrentEndTime());
    if (startTime > endTime) {
        return Collections.emptySet();
    }
    List<@NonNull ISegment> segments = new ArrayList<>();
    try {
        for (ITmfStateInterval interval : fStateSystem.query2D(fSegmentQuarks.keySet(), startTime, endTime)) {
            RequestIntervalSegment segment = RequestIntervalSegment.create(interval, fSegmentQuarks.get(interval.getAttribute()));
            if (segment != null) {
                segments.add(segment);
            }
        }
    } catch (IndexOutOfBoundsException | TimeRangeException | StateSystemDisposedException e1) {
    // Nothing to do
    }
    return segments;
}
Also used : StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) ArrayList(java.util.ArrayList) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 7 with ISegment

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

the class CallStackSegmentStoreTest method testSeriesSegmentStoreIterator.

/**
 * Test the callstack data using the callstack object
 */
@Test
public void testSeriesSegmentStoreIterator() {
    CallStackAnalysisStub module = getModule();
    assertNotNull(module);
    ISegmentStore<@NonNull ISegment> segmentStore = module.getSegmentStore();
    assertNotNull(segmentStore);
    Iterator<@NonNull ISegment> iterator = segmentStore.iterator();
    assertEquals("Segment store iterator count", 21, Iterators.size(iterator));
    assertEquals("Segment store size", 21, segmentStore.size());
    assertFalse(segmentStore.isEmpty());
}
Also used : CallStackAnalysisStub(org.eclipse.tracecompass.analysis.profiling.core.tests.stubs.CallStackAnalysisStub) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) Test(org.junit.Test)

Example 8 with ISegment

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

the class CallStackSegmentStoreTest method testIntersectingSegmentStore.

/**
 * Test the segment store's intersecting query methods
 */
@Test
public void testIntersectingSegmentStore() {
    CallStackAnalysisStub module = getModule();
    assertNotNull(module);
    ISegmentStore<@NonNull ISegment> segmentStore = module.getSegmentStore();
    assertNotNull(segmentStore);
    // Test with some boundaries: all elements that start or end at 10 should be
    // included
    Iterable<@NonNull ISegment> elements = segmentStore.getIntersectingElements(10L);
    assertEquals("Intersecting 10", 9, Iterables.size(elements));
    elements = segmentStore.getIntersectingElements(10L, 15L);
    assertEquals("Between 10 and 15", 12, Iterables.size(elements));
}
Also used : CallStackAnalysisStub(org.eclipse.tracecompass.analysis.profiling.core.tests.stubs.CallStackAnalysisStub) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) Test(org.junit.Test)

Example 9 with ISegment

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

the class CallStackSeries method getIntersectingElements.

/**
 * Retrieve all elements that inclusively cross another segment and evaluate
 * a predicate to true. We define this target segment by its start and end
 * positions.
 *
 * This effectively means, all elements that respect *all* conditions:
 *
 * <ul>
 * <li>Their end is after the 'start' parameter</li>
 * <li>Their start is before the 'end' parameter</li>
 * <li>They match the predicate</li>
 * </ul>
 *
 * @param start
 *            The target start position
 * @param end
 *            The target end position
 * @param intervalTest
 *            A {@link Predicate} object. The predicate must evaluate to
 *            true in order to consider the interval, otherwise the interval
 *            is ignored
 * @return The elements overlapping with this segment
 * @since 2.2
 */
protected Iterable<ISegment> getIntersectingElements(long start, long end, Predicate<ITmfStateInterval> intervalTest) {
    ITmfStateSystem stateSystem = fRootGroup.getStateSystem();
    long startTime = Math.max(SaturatedArithmetic.add(start, -1L), stateSystem.getStartTime());
    long endTime = Math.min(end, stateSystem.getCurrentEndTime());
    if (startTime > endTime) {
        return Collections.emptyList();
    }
    Map<Integer, CallStack> quarksToElement = getCallStackQuarks();
    try {
        Iterable<ITmfStateInterval> query2d = stateSystem.query2D(quarksToElement.keySet(), startTime, endTime);
        query2d = Iterables.filter(query2d, interval -> !interval.getStateValue().isNull() && intervalTest.test(interval));
        Function<ITmfStateInterval, ICalledFunction> fct = interval -> {
            CallStack callstack = quarksToElement.get(interval.getAttribute());
            if (callstack == null) {
                // $NON-NLS-1$
                throw new NullPointerException("The quark was in that map in the first place, there must be a callstack to go with it!");
            }
            int pid = callstack.getSymbolKeyAt(interval.getStartTime());
            return CalledFunctionFactory.create(interval.getStartTime(), interval.getEndTime() + 1, Integer.parseInt(stateSystem.getAttributeName(interval.getAttribute())), Objects.requireNonNull(interval.getValue()), pid, null);
        };
        return Iterables.transform(query2d, fct);
    } catch (StateSystemDisposedException e) {
        // $NON-NLS-1$
        Activator.getInstance().logError("Error getting intersecting elements: StateSystemDisposed");
    }
    return Collections.emptyList();
}
Also used : ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) Iterables(com.google.common.collect.Iterables) HashMap(java.util.HashMap) Iterators(com.google.common.collect.Iterators) ArrayList(java.util.ArrayList) Nullable(org.eclipse.jdt.annotation.Nullable) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Map(java.util.Map) Activator(org.eclipse.tracecompass.internal.analysis.profiling.core.Activator) IHostIdResolver(org.eclipse.tracecompass.analysis.profiling.core.callstack.CallStackHostUtils.IHostIdResolver) StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) InstrumentedProfilingElement(org.eclipse.tracecompass.internal.analysis.profiling.core.callstack.InstrumentedProfilingElement) ISegmentStore(org.eclipse.tracecompass.segmentstore.core.ISegmentStore) CalledFunctionFactory(org.eclipse.tracecompass.internal.analysis.profiling.core.callgraph.CalledFunctionFactory) Function(com.google.common.base.Function) Iterator(java.util.Iterator) IProfilingElement(org.eclipse.tracecompass.analysis.profiling.core.base.IProfilingElement) IProfilingGroupDescriptor(org.eclipse.tracecompass.analysis.profiling.core.base.IProfilingGroupDescriptor) ICalledFunction(org.eclipse.tracecompass.internal.analysis.profiling.core.callgraph.ICalledFunction) IHostIdProvider(org.eclipse.tracecompass.analysis.profiling.core.callstack.CallStackHostUtils.IHostIdProvider) Predicate(java.util.function.Predicate) Collection(java.util.Collection) SaturatedArithmetic(org.eclipse.tracecompass.common.core.math.SaturatedArithmetic) Objects(java.util.Objects) List(java.util.List) InstrumentedGroupDescriptor(org.eclipse.tracecompass.internal.analysis.profiling.core.callstack.InstrumentedGroupDescriptor) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) Collections(java.util.Collections) NonNull(org.eclipse.jdt.annotation.NonNull) ICalledFunction(org.eclipse.tracecompass.internal.analysis.profiling.core.callgraph.ICalledFunction) StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)

Example 10 with ISegment

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

the class CallStackSeries method contains.

@Override
public boolean contains(@Nullable Object o) {
    // narrow down search when object is a segment
    if (o instanceof ICalledFunction) {
        ICalledFunction seg = (ICalledFunction) o;
        Iterable<@NonNull ISegment> iterable = getIntersectingElements(seg.getStart());
        return Iterables.contains(iterable, seg);
    }
    return false;
}
Also used : ICalledFunction(org.eclipse.tracecompass.internal.analysis.profiling.core.callgraph.ICalledFunction) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment)

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