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;
}
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));
}
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());
}
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();
}
}
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());
}
Aggregations