Search in sources :

Example 1 with ISegment

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

the class UstMemoryAnalysisModule method executeAnalysis.

@Override
protected boolean executeAnalysis(IProgressMonitor monitor) {
    if (!super.executeAnalysis(monitor)) {
        return false;
    }
    ITmfTrace trace = checkNotNull(getTrace());
    // $NON-NLS-1$
    String segmentFileName = getSsFileName() + ".seg";
    /* See if the data file already exists on disk */
    String dir = TmfTraceManager.getSupplementaryFileDir(trace);
    final Path file = Paths.get(dir, segmentFileName);
    boolean needsBuilding = true;
    Map<Long, MemoryAllocation> unfreedMemory = fPotentialLeaks;
    if (unfreedMemory == null || unfreedMemory.isEmpty()) {
        needsBuilding = false;
    }
    ISegmentStore<@NonNull ISegment> segmentStore = null;
    try {
        if (needsBuilding) {
            Files.deleteIfExists(file);
        }
        segmentStore = SegmentStoreFactory.createOnDiskSegmentStore(file, PotentialLeakSegment.MEMORY_SEGMENT_READ_FACTORY, 1);
    } catch (IOException e) {
        return false;
    }
    if (needsBuilding) {
        fillStore(segmentStore, unfreedMemory);
    }
    fSegmentStore = segmentStore;
    sendUpdate(segmentStore);
    return true;
}
Also used : Path(java.nio.file.Path) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) MemoryAllocation(org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory.UstMemoryStateProvider.MemoryAllocation) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) NonNullUtils.nullToEmptyString(org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString) IOException(java.io.IOException)

Example 2 with ISegment

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

the class XmlSegmentTest method doTestSegmentContent.

private static void doTestSegmentContent(XmlPatternAnalysis module) {
    @Nullable ISegmentStore<@NonNull ISegment> ss = module.getSegmentStore();
    assertNotNull(ss);
    assertEquals("Segment store size", 4, ss.size());
    Iterator<@NonNull ISegment> iterator = ss.iterator();
    // first segment
    assertTrue(iterator.hasNext());
    ISegment segment1 = iterator.next();
    assertTrue(segment1 instanceof TmfXmlPatternSegment);
    XmlUtilsTest.testPatternSegmentData(SEGMENT_1, (TmfXmlPatternSegment) segment1);
    // second segment
    assertTrue(iterator.hasNext());
    ISegment segment2 = iterator.next();
    assertTrue(segment2 instanceof TmfXmlPatternSegment);
    XmlUtilsTest.testPatternSegmentData(SEGMENT_2, (TmfXmlPatternSegment) segment2);
    // third segment
    assertTrue(iterator.hasNext());
    ISegment segment3 = iterator.next();
    assertTrue(segment3 instanceof TmfXmlPatternSegment);
    XmlUtilsTest.testPatternSegmentData(SEGMENT_3, (TmfXmlPatternSegment) segment3);
    // fourth segment
    assertTrue(iterator.hasNext());
    ISegment segment4 = iterator.next();
    assertTrue(segment4 instanceof TmfXmlPatternSegment);
    XmlUtilsTest.testPatternSegmentData(SEGMENT_4, (TmfXmlPatternSegment) segment4);
    assertFalse(iterator.hasNext());
    // Compare segments
    // segment1 < segment3, comparison by string (end time)
    assertEquals(-1, segment1.compareTo(segment3));
    assertEquals(1, segment3.compareTo(segment1));
    // segment1 < segment2, comparison by name
    assertEquals(-1, segment1.compareTo(segment2));
    assertEquals(1, segment2.compareTo(segment1));
    assertEquals(0, segment2.compareTo(segment2));
    // segment2 < segment4, comparison by content
    assertEquals(-1, segment2.compareTo(segment4));
    assertEquals(1, segment4.compareTo(segment2));
}
Also used : TmfXmlPatternSegment(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.segment.TmfXmlPatternSegment) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 3 with ISegment

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

the class PatternProvidersTest method testSegmentStore.

/**
 * Test the generated segment store
 */
@Test
public void testSegmentStore() {
    TmfAbstractAnalysisModule module = getModule();
    if (module instanceof ITmfAnalysisModuleWithStateSystems) {
        // In this test, the module will be XmlPatternAnalysis which is an instance of ITmfAnalysisModuleWithStateSystems
        assertTrue(((ITmfAnalysisModuleWithStateSystems) module).waitForInitialization());
    }
    assertTrue(module.waitForCompletion());
    ISegmentStore<@NonNull ISegment> ss = ((ISegmentStoreProvider) module).getSegmentStore();
    assertNotNull(ss);
    assertFalse(ss.isEmpty());
}
Also used : ISegmentStoreProvider(org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) TmfAbstractAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule) ITmfAnalysisModuleWithStateSystems(org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems) Test(org.junit.Test)

Example 4 with ISegment

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

the class TmfXmlConditionTest method testConditionsPattern.

/**
 * Test time range and elapsed validations
 */
@Test
public void testConditionsPattern() {
    ITmfTrace trace = XmlUtilsTest.initializeTrace(testTrace4);
    XmlPatternAnalysis module = XmlUtilsTest.initializePatternModule(TmfXmlTestFiles.VALID_PATTERN_SIMPLE_FILE);
    try {
        module.setTrace(trace);
        module.schedule();
        module.waitForCompletion();
        ISegmentStore<@NonNull ISegment> segmentStore = module.getSegmentStore();
        assertNotNull(segmentStore);
        assertEquals(1, segmentStore.size());
        Iterator<@NonNull ISegment> elements = segmentStore.getIntersectingElements(6).iterator();
        assertTrue(elements.hasNext());
        ISegment next = elements.next();
        assertEquals(5, next.getStart());
        assertEquals(2, next.getLength());
    } catch (TmfAnalysisException e) {
        fail(e.getMessage());
    } finally {
        module.dispose();
        trace.dispose();
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) XmlPatternAnalysis(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) Test(org.junit.Test) XmlUtilsTest(org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest)

Example 5 with ISegment

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

the class SyscallAnalysisTest method testSmallTraceSequential.

/**
 * This will load the analysis and test it. as it depends on Kernel, this
 * test runs the kernel trace first then the analysis
 */
@Test
public void testSmallTraceSequential() {
    final SystemCallLatencyAnalysis syscallModule = fSyscallModule;
    assertNotNull(syscallModule);
    ISegmentStore<@NonNull ISegment> segmentStore = syscallModule.getSegmentStore();
    assertNotNull(segmentStore);
    assertEquals(1801, segmentStore.size());
}
Also used : SystemCallLatencyAnalysis(org.eclipse.tracecompass.internal.analysis.os.linux.core.latency.SystemCallLatencyAnalysis) 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