use of org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph in project tracecompass by tracecompass.
the class TmfCriticalPathAlgorithmTest method testCriticalPath.
private void testCriticalPath(GraphBuilder builder, IGraphWorker obj) {
/* Get the base graph */
TmfGraph main = builder.build();
assertNotNull(main);
/* The expected critical path */
TmfGraph expected = getExpectedCriticalPath(builder);
assertNotNull(expected);
/* The actual critical path */
TmfVertex head = null;
if (obj == null) {
head = main.getHead();
} else {
head = main.getHead(obj);
}
assertNotNull(head);
TmfGraph actual = computeCriticalPath(main, head);
assertNotNull(actual);
/* Check the 2 graphs are equivalent */
GraphOps.checkEquality(expected, actual);
}
use of org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph in project tracecompass by tracecompass.
the class TmfGraphBuilderModuleTest method testBuildGraph.
/**
* Test the graph builder execution
*/
@Test
public void testBuildGraph() {
TmfXmlTraceStub trace = TmfXmlTraceStubNs.setupTrace(Activator.getAbsoluteFilePath(STUB_TRACE_FILE));
TmfGraphBuilderModule module = getModule(trace);
module.schedule();
module.waitForCompletion();
TmfGraph graph = module.getGraph();
assertNotNull(graph);
assertEquals(2, graph.getWorkers().size());
assertEquals(9, graph.size());
List<TmfVertex> vertices = graph.getNodesOf(new TestGraphWorker(1));
assertEquals(5, vertices.size());
long[] timestamps1 = { 1, 2, 5, 7, 12 };
boolean[][] hasEdges1 = { { false, true, false, false }, { true, false, false, true }, { false, true, true, false }, { true, false, false, false }, { false, false, true, false } };
for (int i = 0; i < vertices.size(); i++) {
TmfVertex v = vertices.get(i);
assertEquals(timestamps1[i], v.getTs());
assertEquals(hasEdges1[i][0], v.getEdge(EdgeDirection.INCOMING_HORIZONTAL_EDGE) != null);
assertEquals(hasEdges1[i][1], v.getEdge(EdgeDirection.OUTGOING_HORIZONTAL_EDGE) != null);
assertEquals(hasEdges1[i][2], v.getEdge(EdgeDirection.INCOMING_VERTICAL_EDGE) != null);
assertEquals(hasEdges1[i][3], v.getEdge(EdgeDirection.OUTGOING_VERTICAL_EDGE) != null);
}
vertices = graph.getNodesOf(new TestGraphWorker(2));
assertEquals(4, vertices.size());
long[] timestamps2 = { 2, 5, 10, 12 };
boolean[][] hasEdges2 = { { false, true, true, false }, { true, false, false, true }, { false, true, false, false }, { true, false, false, true } };
for (int i = 0; i < vertices.size(); i++) {
TmfVertex v = vertices.get(i);
assertEquals(timestamps2[i], v.getTs());
assertEquals(hasEdges2[i][0], v.getEdge(EdgeDirection.INCOMING_HORIZONTAL_EDGE) != null);
assertEquals(hasEdges2[i][1], v.getEdge(EdgeDirection.OUTGOING_HORIZONTAL_EDGE) != null);
assertEquals(hasEdges2[i][2], v.getEdge(EdgeDirection.INCOMING_VERTICAL_EDGE) != null);
assertEquals(hasEdges2[i][3], v.getEdge(EdgeDirection.OUTGOING_VERTICAL_EDGE) != null);
}
trace.dispose();
}
use of org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph in project tracecompass by tracecompass.
the class TmfGraphTest method testDefaultConstructor.
/**
* Test the graph constructor
*/
@Test
public void testDefaultConstructor() {
TmfGraph g = new TmfGraph();
assertEquals(0, g.size());
}
use of org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph in project tracecompass by tracecompass.
the class TmfGraphTest method testScanCount.
/**
* Test the {@link TmfGraph#scanLineTraverse(IGraphWorker, ITmfGraphVisitor)} method
*/
@Test
public void testScanCount() {
TmfGraph graph = buildFullGraph();
ScanCountVertex visitor = new ScanCountVertex();
graph.scanLineTraverse(graph.getHead(WORKER1), visitor);
assertEquals(21, visitor.nbVertex);
assertEquals(6, visitor.nbStartVertex);
assertEquals(5, visitor.nbVLink);
assertEquals(15, visitor.nbHLink);
}
use of org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph in project tracecompass by tracecompass.
the class TmfGraphTest method testGraphStatistics.
/**
* Test the {@link TmfGraphStatistics} class
*/
@Test
public void testGraphStatistics() {
TmfGraph graph = buildFullGraph();
TmfGraphStatistics stats = new TmfGraphStatistics();
stats.computeGraphStatistics(graph, WORKER1);
assertEquals(12, stats.getSum(WORKER1).longValue());
assertEquals(11, stats.getSum(WORKER2).longValue());
assertEquals(23, stats.getSum().longValue());
}
Aggregations