Search in sources :

Example 1 with SampleGraph

use of org.spf4j.stackmonitor.SampleGraph in project spf4j by zolyfarkas.

the class FlameStackPanelTest method testSampleGraph.

@Test
public void testSampleGraph() throws IOException, InterruptedException {
    LOG.debug("Graph = {}", NODES2);
    SampleGraph sg = new SampleGraph(Methods.ROOT, NODES2);
    SampleGraph.AggSample aggRootVertex = sg.getAggRootVertex();
    SampleGraph.AggSample child = sg.getChildren(aggRootVertex).iterator().next();
    Assert.assertTrue(sg.isParentDescendant(aggRootVertex, child));
}
Also used : SampleGraph(org.spf4j.stackmonitor.SampleGraph) Test(org.junit.Test)

Example 2 with SampleGraph

use of org.spf4j.stackmonitor.SampleGraph in project spf4j by zolyfarkas.

the class HotFlameStackPanel method paintGraph.

private void paintGraph(final Graphics2D g2, final double areaWidth, final double rowHeight) {
    SampleNode samples = getSamples();
    if (samples == null) {
        return;
    }
    final SampleGraph graph = new SampleGraph(getMethod(), samples);
    this.completeGraph = graph;
    AggSample aggRoot = graph.getAggRootVertex();
    int rootSamples = aggRoot.getNrSamples();
    // calculate pixe/sample
    final double pps = (areaWidth - 1) / rootSamples;
    methodLocations = new HashMap<>();
    PriorityQueue<AggSample> traversal = new PriorityQueue<>(new SComparator(graph));
    traversal.add(aggRoot);
    Set<AggSample> drawed = new HashSet<>(graph.getAggNodesNr());
    AggSample next;
    while ((next = traversal.poll()) != null) {
        if (drawed.add(next)) {
            drawMethod(g2, next, graph, pps, rowHeight);
            traversal.addAll(graph.getChildren(next));
        }
    }
}
Also used : SampleNode(org.spf4j.stackmonitor.SampleNode) SampleGraph(org.spf4j.stackmonitor.SampleGraph) AggSample(org.spf4j.stackmonitor.SampleGraph.AggSample) PriorityQueue(java.util.PriorityQueue) Point(java.awt.Point) HashSet(java.util.HashSet)

Aggregations

SampleGraph (org.spf4j.stackmonitor.SampleGraph)2 Point (java.awt.Point)1 HashSet (java.util.HashSet)1 PriorityQueue (java.util.PriorityQueue)1 Test (org.junit.Test)1 AggSample (org.spf4j.stackmonitor.SampleGraph.AggSample)1 SampleNode (org.spf4j.stackmonitor.SampleNode)1