MCPcopy Create free account
hub / github.com/google/pprof / ComposeDot

Function ComposeDot

internal/graph/dotgraph.go:57–98  ·  view source on GitHub ↗

Number of nodelets for labels (both numeric and non) ComposeDot creates and writes a in the DOT format to the writer, using the configurations given.

(w io.Writer, g *Graph, a *DotAttributes, c *DotConfig)

Source from the content-addressed store, hash-verified

55// ComposeDot creates and writes a in the DOT format to the writer, using
56// the configurations given.
57func ComposeDot(w io.Writer, g *Graph, a *DotAttributes, c *DotConfig) {
58 builder := &builder{w, a, c}
59
60 // Begin constructing DOT by adding a title and legend.
61 builder.start()
62 defer builder.finish()
63 builder.addLegend()
64
65 if len(g.Nodes) == 0 {
66 return
67 }
68
69 // Preprocess graph to get id map and find max flat.
70 nodeIDMap := make(map[*Node]int)
71 hasNodelets := make(map[*Node]bool)
72
73 maxFlat := float64(abs64(g.Nodes[0].FlatValue()))
74 for i, n := range g.Nodes {
75 nodeIDMap[n] = i + 1
76 if float64(abs64(n.FlatValue())) > maxFlat {
77 maxFlat = float64(abs64(n.FlatValue()))
78 }
79 }
80
81 edges := EdgeMap{}
82
83 // Add nodes and nodelets to DOT builder.
84 for _, n := range g.Nodes {
85 builder.addNode(n, nodeIDMap[n], maxFlat)
86 hasNodelets[n] = builder.addNodelets(n, nodeIDMap[n])
87
88 // Collect all edges. Use a fake node to support multiple incoming edges.
89 for _, e := range n.Out {
90 edges[&Node{}] = e
91 }
92 }
93
94 // Add edges to DOT builder. Sort edges by frequency as a hint to the graph layout engine.
95 for _, e := range edges.Sort() {
96 builder.addEdge(e, nodeIDMap[e.Src], nodeIDMap[e.Dest], hasNodelets[e.Src])
97 }
98}
99
100// builder wraps an io.Writer and understands how to compose DOT formatted elements.
101type builder struct {

Calls 9

startMethod · 0.95
finishMethod · 0.95
addLegendMethod · 0.95
addNodeMethod · 0.95
addNodeletsMethod · 0.95
SortMethod · 0.95
addEdgeMethod · 0.95
abs64Function · 0.70
FlatValueMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…