Search in sources :

Example 1 with TmfVertex

use of org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex 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);
}
Also used : TmfVertex(org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex) TmfGraph(org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph)

Example 2 with TmfVertex

use of org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex 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();
}
Also used : TmfVertex(org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex) TmfXmlTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub) TmfGraph(org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph) TestGraphWorker(org.eclipse.tracecompass.analysis.graph.core.tests.stubs.TestGraphWorker) TmfGraphBuilderModule(org.eclipse.tracecompass.analysis.graph.core.building.TmfGraphBuilderModule) Test(org.junit.Test)

Example 3 with TmfVertex

use of org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex in project tracecompass by tracecompass.

the class TmfGraphTest method testAddVertex.

/**
 * Test the {@link TmfGraph#add(IGraphWorker, TmfVertex)} method: vertices are
 * added, but no edge between them is created
 */
@Test
public void testAddVertex() {
    fGraph.add(WORKER1, fV0);
    fGraph.add(WORKER1, fV1);
    List<TmfVertex> list = fGraph.getNodesOf(WORKER1);
    assertEquals(2, list.size());
    for (int i = 0; i < list.size() - 1; i++) {
        TmfVertex vertex = list.get(i);
        assertEquals(i, vertex.getTs());
        assertNull(vertex.getEdge(EdgeDirection.OUTGOING_HORIZONTAL_EDGE));
        assertNull(vertex.getEdge(EdgeDirection.INCOMING_HORIZONTAL_EDGE));
        assertNull(vertex.getEdge(EdgeDirection.OUTGOING_VERTICAL_EDGE));
        assertNull(vertex.getEdge(EdgeDirection.INCOMING_VERTICAL_EDGE));
    }
}
Also used : TmfVertex(org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex) Test(org.junit.Test)

Example 4 with TmfVertex

use of org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex in project tracecompass by tracecompass.

the class TmfGraphTest method testCheckHorizontal.

/**
 * Test the {@link TmfVertex#linkHorizontal(TmfVertex)} with non
 * chronological timestamps
 */
@Test(expected = IllegalArgumentException.class)
public void testCheckHorizontal() {
    TmfVertex n0 = new TmfVertex(10);
    TmfVertex n1 = new TmfVertex(0);
    n0.linkHorizontal(n1);
}
Also used : TmfVertex(org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex) Test(org.junit.Test)

Example 5 with TmfVertex

use of org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex in project tracecompass by tracecompass.

the class TmfGraphTest method testHorizontalSelfLink.

/**
 * Test that exception is thrown if a node is linked horizontally to itself
 */
@Test(expected = IllegalArgumentException.class)
public void testHorizontalSelfLink() {
    TmfVertex n0 = new TmfVertex(0);
    n0.linkHorizontal(n0);
}
Also used : TmfVertex(org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex) Test(org.junit.Test)

Aggregations

TmfVertex (org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex)38 TmfGraph (org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph)16 TmfEdge (org.eclipse.tracecompass.analysis.graph.core.base.TmfEdge)15 Test (org.junit.Test)12 IGraphWorker (org.eclipse.tracecompass.analysis.graph.core.base.IGraphWorker)11 OsWorker (org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsWorker)10 TmfGraphBuilderModule (org.eclipse.tracecompass.analysis.graph.core.building.TmfGraphBuilderModule)7 HashMap (java.util.HashMap)4 CriticalPathModule (org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule)4 Context (org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsExecutionGraphProvider.Context)3 OsInterruptContext (org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsInterruptContext)3 TmfCpuAspect (org.eclipse.tracecompass.tmf.core.event.aspect.TmfCpuAspect)3 OsSystemModel (org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsSystemModel)2 ProcessStatus (org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus)2 ITmfEventField (org.eclipse.tracecompass.tmf.core.event.ITmfEventField)2 DependencyEvent (org.eclipse.tracecompass.tmf.core.event.matching.TmfEventDependency.DependencyEvent)2 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1