Search in sources :

Example 1 with TmfGraph

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

Example 2 with TmfGraph

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

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

Example 4 with TmfGraph

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

Example 5 with TmfGraph

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());
}
Also used : TmfGraph(org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph) TmfGraphStatistics(org.eclipse.tracecompass.internal.analysis.graph.core.base.TmfGraphStatistics) Test(org.junit.Test)

Aggregations

TmfGraph (org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph)24 TmfVertex (org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex)16 IGraphWorker (org.eclipse.tracecompass.analysis.graph.core.base.IGraphWorker)11 OsWorker (org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsWorker)8 TmfGraphBuilderModule (org.eclipse.tracecompass.analysis.graph.core.building.TmfGraphBuilderModule)7 Test (org.junit.Test)7 TmfEdge (org.eclipse.tracecompass.analysis.graph.core.base.TmfEdge)5 CriticalPathModule (org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule)5 HashMap (java.util.HashMap)4 ProcessStatus (org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus)3 NonNull (org.eclipse.jdt.annotation.NonNull)2 IKernelAnalysisEventLayout (org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout)2 TmfCpuAspect (org.eclipse.tracecompass.tmf.core.event.aspect.TmfCpuAspect)2 TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CriticalPathAlgorithmException (org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathAlgorithmException)1 TestGraphWorker (org.eclipse.tracecompass.analysis.graph.core.tests.stubs.TestGraphWorker)1 OsSystemModel (org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsSystemModel)1 HostThread (org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread)1