Search in sources :

Example 1 with BasicSegment

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

the class SegmentAspectTest method aspectResolveTest.

/**
 * Tests the resolve method
 */
@Test
public void aspectResolveTest() {
    long start = 1;
    long end = 3;
    BasicSegment segment = new BasicSegment(start, end);
    assertEquals((long) 0, ASPECT_STUB.resolve(segment));
    assertEquals(start, START_ASPECT.resolve(segment));
    assertEquals(end, END_ASPECT.resolve(segment));
    assertEquals(end - start, DURATION_ASPECT.resolve(segment));
}
Also used : BasicSegment(org.eclipse.tracecompass.segmentstore.core.BasicSegment) Test(org.junit.Test)

Example 2 with BasicSegment

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

the class SegmentTableTest method onDiskSegStoreTest.

/**
 * Test table with an on-disk segment store that is lazy loaded in the table
 *
 * @throws IOException
 *             when creating the segment store
 */
@Test
public void onDiskSegStoreTest() throws IOException {
    Path segmentFile = Files.createTempFile("tmpSegStore", ".tmp");
    assertNotNull(segmentFile);
    ISegmentStore<@NonNull BasicSegment> fixture = null;
    try {
        final int size = 1000000;
        fixture = SegmentStoreFactory.createOnDiskSegmentStore(segmentFile, BasicSegment.BASIC_SEGMENT_READ_FACTORY, 1);
        for (int i = 0; i < size; i++) {
            fixture.add(new BasicSegment(i, 2 * i));
        }
        fixture.close(false);
        assertNotNull(getTable());
        getTable().updateModel(fixture);
        SWTBotTable tableBot = new SWTBotTable(getTable().getTableViewer().getTable());
        fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "0", 0, 2));
        tableBot.header("Duration").click();
        fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "0", 0, 2));
        tableBot.header("Duration").click();
        fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "999,999", 0, 2));
    } finally {
        if (fixture != null) {
            fixture.close(true);
        }
        Files.deleteIfExists(segmentFile);
    }
}
Also used : Path(java.nio.file.Path) BasicSegment(org.eclipse.tracecompass.segmentstore.core.BasicSegment) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) Test(org.junit.Test)

Example 3 with BasicSegment

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

the class SegmentStoreBenchmark method assertOrder.

private static void assertOrder(ISegmentStore<@NonNull BasicSegment> store, Comparator<@NonNull ISegment> order) {
    Iterable<@NonNull BasicSegment> iterable = store.iterator(order);
    BasicSegment prev = null;
    long count = 0L;
    for (BasicSegment segment : iterable) {
        if (prev != null) {
            assertTrue("Incorrect iteration order at: " + count + ", prev: " + prev + ", current: " + segment, order.compare(prev, segment) <= 0);
        }
        prev = segment;
        count++;
    }
}
Also used : BasicSegment(org.eclipse.tracecompass.segmentstore.core.BasicSegment)

Example 4 with BasicSegment

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

the class SegmentStoreBenchmark method populate.

private static void populate(int size, int[] fuzz, ISegmentStore<@NonNull BasicSegment> store, long low, long high) {
    for (long i = low; i < high; i++) {
        long start = i + fuzz[(int) (i % size)];
        store.add(new BasicSegment(start, start + 10));
    }
}
Also used : BasicSegment(org.eclipse.tracecompass.segmentstore.core.BasicSegment)

Example 5 with BasicSegment

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

the class AbstractTestSegmentStore method testContains.

/**
 * Test the contains() method.
 */
@Test
public void testContains() {
    ISegment otherSegment = new BasicSegment(0, 20);
    assertTrue(fSegmentStore.contains(SEGMENT_2_6));
    assertTrue(fSegmentStore.contains(SEGMENT_4_8));
    assertFalse(fSegmentStore.contains(otherSegment));
}
Also used : BasicSegment(org.eclipse.tracecompass.segmentstore.core.BasicSegment) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) Test(org.junit.Test)

Aggregations

BasicSegment (org.eclipse.tracecompass.segmentstore.core.BasicSegment)16 Test (org.junit.Test)8 ISegment (org.eclipse.tracecompass.segmentstore.core.ISegment)6 ArrayList (java.util.ArrayList)2 HTCoreNodeTest (org.eclipse.tracecompass.internal.provisional.datastore.core.historytree.HTCoreNodeTest)2 SegmentTreeNodeStub (org.eclipse.tracecompass.segmentstore.core.tests.historytree.SegmentTreeNodeStub)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 File (java.io.File)1 IOException (java.io.IOException)1 ClosedChannelException (java.nio.channels.ClosedChannelException)1 Path (java.nio.file.Path)1 Collection (java.util.Collection)1 Comparator (java.util.Comparator)1 Deque (java.util.Deque)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 NavigableSet (java.util.NavigableSet)1 NoSuchElementException (java.util.NoSuchElementException)1 PriorityQueue (java.util.PriorityQueue)1 NonNull (org.eclipse.jdt.annotation.NonNull)1