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

Method addNodelets

internal/graph/dotgraph.go:216–263  ·  view source on GitHub ↗

addNodelets generates the DOT boxes for the node tags if they exist.

(node *Node, nodeID int)

Source from the content-addressed store, hash-verified

214
215// addNodelets generates the DOT boxes for the node tags if they exist.
216func (b *builder) addNodelets(node *Node, nodeID int) bool {
217 var nodelets string
218
219 // Populate two Tag slices, one for LabelTags and one for NumericTags.
220 var ts []*Tag
221 lnts := make(map[string][]*Tag)
222 for _, t := range node.LabelTags {
223 ts = append(ts, t)
224 }
225 for l, tm := range node.NumericTags {
226 for _, t := range tm {
227 lnts[l] = append(lnts[l], t)
228 }
229 }
230
231 // For leaf nodes, print cumulative tags (includes weight from
232 // children that have been deleted).
233 // For internal nodes, print only flat tags.
234 flatTags := len(node.Out) > 0
235
236 // Select the top maxNodelets alphanumeric labels by weight.
237 SortTags(ts, flatTags)
238 if len(ts) > maxNodelets {
239 ts = ts[:maxNodelets]
240 }
241 for i, t := range ts {
242 w := t.CumValue()
243 if flatTags {
244 w = t.FlatValue()
245 }
246 if w == 0 {
247 continue
248 }
249 weight := b.config.FormatValue(w)
250 nodelets += fmt.Sprintf(`N%d_%d [label = "%s" id="N%d_%d" fontsize=8 shape=box3d tooltip="%s"]`+"\n", nodeID, i, t.Name, nodeID, i, weight)
251 nodelets += fmt.Sprintf(`N%d -> N%d_%d [label=" %s" weight=100 tooltip="%s" labeltooltip="%s"]`+"\n", nodeID, nodeID, i, weight, weight, weight)
252 if nts := lnts[t.Name]; nts != nil {
253 nodelets += b.numericNodelets(nts, maxNodelets, flatTags, fmt.Sprintf(`N%d_%d`, nodeID, i))
254 }
255 }
256
257 if nts := lnts[""]; nts != nil {
258 nodelets += b.numericNodelets(nts, maxNodelets, flatTags, fmt.Sprintf(`N%d`, nodeID))
259 }
260
261 fmt.Fprint(b, nodelets)
262 return nodelets != ""
263}
264
265func (b *builder) numericNodelets(nts []*Tag, maxNumNodelets int, flatTags bool, source string) string {
266 nodelets := ""

Callers 1

ComposeDotFunction · 0.95

Calls 4

numericNodeletsMethod · 0.95
SortTagsFunction · 0.85
CumValueMethod · 0.45
FlatValueMethod · 0.45

Tested by

no test coverage detected