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

Method addEdge

internal/graph/dotgraph.go:285–322  ·  view source on GitHub ↗

addEdge generates a graph edge in DOT format.

(edge *Edge, from, to int, hasNodelets bool)

Source from the content-addressed store, hash-verified

283
284// addEdge generates a graph edge in DOT format.
285func (b *builder) addEdge(edge *Edge, from, to int, hasNodelets bool) {
286 var inline string
287 if edge.Inline {
288 inline = `\n (inline)`
289 }
290 w := b.config.FormatValue(edge.WeightValue())
291 attr := fmt.Sprintf(`label=" %s%s"`, w, inline)
292 if b.config.Total != 0 {
293 // Note: edge.weight > b.config.Total is possible for profile diffs.
294 if weight := 1 + int(min64(abs64(edge.WeightValue()*100/b.config.Total), 100)); weight > 1 {
295 attr = fmt.Sprintf(`%s weight=%d`, attr, weight)
296 }
297 if width := 1 + int(min64(abs64(edge.WeightValue()*5/b.config.Total), 5)); width > 1 {
298 attr = fmt.Sprintf(`%s penwidth=%d`, attr, width)
299 }
300 attr = fmt.Sprintf(`%s color="%s"`, attr,
301 dotColor(float64(edge.WeightValue())/float64(abs64(b.config.Total)), false))
302 }
303 arrow := "->"
304 if edge.Residual {
305 arrow = "..."
306 }
307 tooltip := fmt.Sprintf(`"%s %s %s (%s)"`,
308 escapeForDot(edge.Src.Info.PrintableName()), arrow,
309 escapeForDot(edge.Dest.Info.PrintableName()), w)
310 attr = fmt.Sprintf(`%s tooltip=%s labeltooltip=%s`, attr, tooltip, tooltip)
311
312 if edge.Residual {
313 attr = attr + ` style="dotted"`
314 }
315
316 if hasNodelets {
317 // Separate children further if source has tags.
318 attr = attr + " minlen=2"
319 }
320
321 fmt.Fprintf(b, "N%d -> N%d [%s]\n", from, to, attr)
322}
323
324// dotColor returns a color for the given score (between -1.0 and
325// 1.0), with -1.0 colored green, 0.0 colored grey, and 1.0 colored

Callers 1

ComposeDotFunction · 0.95

Calls 6

min64Function · 0.85
dotColorFunction · 0.85
escapeForDotFunction · 0.85
WeightValueMethod · 0.80
PrintableNameMethod · 0.80
abs64Function · 0.70

Tested by

no test coverage detected