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

Method selectTopNodes

internal/graph/graph.go:856–875  ·  view source on GitHub ↗

selectTopNodes returns a slice of the top maxNodes nodes in a graph.

(maxNodes int, visualMode bool)

Source from the content-addressed store, hash-verified

854
855// selectTopNodes returns a slice of the top maxNodes nodes in a graph.
856func (g *Graph) selectTopNodes(maxNodes int, visualMode bool) Nodes {
857 if maxNodes > 0 {
858 if visualMode {
859 var count int
860 // If generating a visual graph, count tags as nodes. Update
861 // maxNodes to account for them.
862 for i, n := range g.Nodes {
863 tags := min(countTags(n), maxNodelets)
864 if count += tags + 1; count >= maxNodes {
865 maxNodes = i + 1
866 break
867 }
868 }
869 }
870 }
871 if maxNodes > len(g.Nodes) {
872 maxNodes = len(g.Nodes)
873 }
874 return g.Nodes[:maxNodes]
875}
876
877// countTags counts the tags with flat count. This underestimates the
878// number of tags being displayed, but in practice is close enough.

Callers 2

SelectTopNodePtrsMethod · 0.95
SelectTopNodesMethod · 0.95

Calls 1

countTagsFunction · 0.85

Tested by

no test coverage detected