Search in sources :

Example 26 with ISegment

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

the class SegmentStoreFactoryTest method createPreloaded.

/**
 * Create a pre-loaded fast segment store
 */
@Test
public void createPreloaded() {
    ISegment[] data = new ISegment[1];
    data[0] = new BasicSegment(0, 0);
    ISegmentStore<@NonNull ISegment> segmentStore;
    segmentStore = SegmentStoreFactory.createSegmentStore(data);
    assertNotNull(segmentStore);
    assertEquals(1, segmentStore.size());
    segmentStore = SegmentStoreFactory.createSegmentStore(data, SegmentStoreType.Fast);
    assertNotNull(segmentStore);
    assertEquals(1, segmentStore.size());
    segmentStore = SegmentStoreFactory.createSegmentStore(data, SegmentStoreType.Stable);
    assertNotNull(segmentStore);
    assertEquals(1, segmentStore.size());
    segmentStore = SegmentStoreFactory.createSegmentStore(data, SegmentStoreType.Distinct);
    assertNotNull(segmentStore);
    assertEquals(1, segmentStore.size());
}
Also used : BasicSegment(org.eclipse.tracecompass.segmentstore.core.BasicSegment) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) Test(org.junit.Test)

Example 27 with ISegment

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

the class SegmentStoreFactoryTest method testDistinct.

private static void testDistinct(ISegmentStore<@NonNull ISegment> fixture) {
    // test adding the same object
    ISegment seg = new BasicSegment(0, 0);
    fixture.add(seg);
    fixture.add(seg);
    assertEquals(1, fixture.size());
    fixture.clear();
    // test different equal objects
    fixture.add(new BasicSegment(0, 0));
    fixture.add(new BasicSegment(0, 0));
    assertEquals(1, fixture.size());
}
Also used : BasicSegment(org.eclipse.tracecompass.segmentstore.core.BasicSegment) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment)

Example 28 with ISegment

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

the class INamedSegmentTest method testComparator.

/**
 * Test the {@link SegmentTypeComparators#NAMED_SEGMENT_COMPARATOR}
 * comparator
 */
@Test
public void testComparator() {
    Comparator<ISegment> cmp = SegmentTypeComparators.NAMED_SEGMENT_COMPARATOR;
    // Verify the comparator with the segments
    assertEquals(cmp.compare(NAMED_SEGMENT2, NAMED_SEGMENT3), cmp.compare(NAMED_SEGMENT3, NAMED_SEGMENT2));
    assertTrue(cmp.compare(NAMED_SEGMENT1, NAMED_SEGMENT2) > 0);
    assertEquals(cmp.compare(NAMED_SEGMENT1, NAMED_SEGMENT2), -1 * cmp.compare(NAMED_SEGMENT2, NAMED_SEGMENT1));
    assertTrue(cmp.compare(BASE_SEGMENT, NAMED_SEGMENT2) > 0);
    assertTrue(cmp.compare(NAMED_SEGMENT2, BASE_SEGMENT) < 0);
    assertTrue(cmp.compare(BASE_SEGMENT, NAMED_SEGMENT4) > 0);
    assertTrue(cmp.compare(NAMED_SEGMENT4, BASE_SEGMENT) < 0);
    // Add the segments to a segment store
    ISegmentStore<BasicSegment> segStore = SegmentStoreFactory.createSegmentStore(SegmentStoreType.Fast);
    segStore.add(BASE_SEGMENT);
    segStore.add(NAMED_SEGMENT1);
    segStore.add(NAMED_SEGMENT2);
    segStore.add(NAMED_SEGMENT3);
    segStore.add(NAMED_SEGMENT4);
    // Iterate with this comparator on the segment store
    Iterable<BasicSegment> iterable = segStore.iterator(cmp);
    Iterator<BasicSegment> iterator = iterable.iterator();
    assertTrue(iterator.hasNext());
    BasicSegment current = iterator.next();
    BasicSegment prev = current;
    int count = 1;
    while (iterator.hasNext()) {
        current = iterator.next();
        assertTrue(cmp.compare(prev, current) <= 0);
        prev = current;
        count++;
    }
    assertEquals(5, count);
    // Iterate with the reverse comparator
    iterable = segStore.iterator(NonNullUtils.checkNotNull(cmp.reversed()));
    iterator = iterable.iterator();
    assertTrue(iterator.hasNext());
    current = iterator.next();
    prev = current;
    count = 1;
    while (iterator.hasNext()) {
        current = iterator.next();
        assertTrue(cmp.compare(prev, current) >= 0);
        prev = current;
        count++;
    }
    assertEquals(5, count);
}
Also used : BasicSegment(org.eclipse.tracecompass.segmentstore.core.BasicSegment) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) Test(org.junit.Test)

Example 29 with ISegment

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

the class AbstractStatsAnalysisTest method testTotalStats.

/**
 * Test total statistics
 *
 * @throws TmfAnalysisException
 *             should not happen
 */
@Test
public void testTotalStats() throws TmfAnalysisException {
    TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
    StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
    IStatistics<@NonNull ISegment> totalStats = fixture.getStatsTotal();
    assertNotNull(totalStats);
    // no need to test the content much as it is tested in the other test.
    assertEquals(StubSegmentStatisticsAnalysis.SIZE, totalStats.getNbElements());
    trace.dispose();
    fixture.dispose();
}
Also used : TmfXmlTraceStubNs(org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs) TmfXmlTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) Test(org.junit.Test)

Example 30 with ISegment

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

the class AbstractStatsAnalysisTest method testPartialPerTypeStats.

/**
 * Test the partial per type statistic
 *
 * @throws TmfAnalysisException
 *             should not happen
 */
@Test
public void testPartialPerTypeStats() throws TmfAnalysisException {
    TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
    StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
    Map<@NonNull String, IStatistics<@NonNull ISegment>> perTypeStats = fixture.getStatsPerTypeForRange(100, 1100, new NullProgressMonitor());
    assertNotNull(perTypeStats);
    // no need to test the content much as it is tested in the other test.
    assertEquals(2, perTypeStats.size());
    assertEquals(ImmutableSet.<String>of("odd", "even"), perTypeStats.keySet());
    IStatistics<@NonNull ISegment> segmentStoreStatistics = perTypeStats.get("even");
    assertNotNull(segmentStoreStatistics);
    // 526 = 1051/2+1 = see explanation of 1051 in #testPartialStats
    assertEquals(526, segmentStoreStatistics.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) NonNull(org.eclipse.jdt.annotation.NonNull) IStatistics(org.eclipse.tracecompass.analysis.timing.core.statistics.IStatistics) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) Test(org.junit.Test)

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