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

Function entropyScore

internal/graph/graph.go:1075–1091  ·  view source on GitHub ↗

entropyScore computes a score for a node representing how important it is to include this node on a graph visualization. It is used to sort the nodes and select which ones to display if we have more nodes than desired in the graph. This number is computed by looking at the flat and cum weights of th

(n *Node)

Source from the content-addressed store, hash-verified

1073// edges. The fundamental idea is to penalize nodes that have a simple
1074// fallthrough from their incoming to the outgoing edge.
1075func entropyScore(n *Node) int64 {
1076 score := float64(0)
1077
1078 if len(n.In) == 0 {
1079 score++ // Favor entry nodes
1080 } else {
1081 score += edgeEntropyScore(n, n.In, 0)
1082 }
1083
1084 if len(n.Out) == 0 {
1085 score++ // Favor leaf nodes
1086 } else {
1087 score += edgeEntropyScore(n, n.Out, n.Flat)
1088 }
1089
1090 return int64(score*float64(n.Cum)) + n.Flat
1091}
1092
1093// edgeEntropyScore computes the entropy value for a set of edges
1094// coming in or out of a node. Entropy (as defined in information

Callers 1

SortMethod · 0.85

Calls 1

edgeEntropyScoreFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…