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

Method Sort

internal/graph/graph.go:958–1060  ·  view source on GitHub ↗

Sort reorders a slice of nodes based on the specified ordering criteria. The result is sorted in decreasing order for (absolute) numeric quantities, alphabetically for text, and increasing for addresses.

(o NodeOrder)

Source from the content-addressed store, hash-verified

956// numeric quantities, alphabetically for text, and increasing for
957// addresses.
958func (ns Nodes) Sort(o NodeOrder) error {
959 var s nodeSorter
960
961 switch o {
962 case FlatNameOrder:
963 s = nodeSorter{ns,
964 func(l, r *Node) bool {
965 if iv, jv := abs64(l.Flat), abs64(r.Flat); iv != jv {
966 return iv > jv
967 }
968 equal, leftLess := l.Info.comparePrintableName(r.Info)
969 if !equal {
970 return leftLess
971 }
972 if iv, jv := abs64(l.Cum), abs64(r.Cum); iv != jv {
973 return iv > jv
974 }
975 return compareNodes(l, r)
976 },
977 }
978 case FlatCumNameOrder:
979 s = nodeSorter{ns,
980 func(l, r *Node) bool {
981 if iv, jv := abs64(l.Flat), abs64(r.Flat); iv != jv {
982 return iv > jv
983 }
984 if iv, jv := abs64(l.Cum), abs64(r.Cum); iv != jv {
985 return iv > jv
986 }
987 equal, leftLess := l.Info.comparePrintableName(r.Info)
988 if !equal {
989 return leftLess
990 }
991 return compareNodes(l, r)
992 },
993 }
994 case NameOrder:
995 s = nodeSorter{ns,
996 func(l, r *Node) bool {
997 if iv, jv := l.Info.Name, r.Info.Name; iv != jv {
998 return iv < jv
999 }
1000 return compareNodes(l, r)
1001 },
1002 }
1003 case FileOrder:
1004 s = nodeSorter{ns,
1005 func(l, r *Node) bool {
1006 if iv, jv := l.Info.File, r.Info.File; iv != jv {
1007 return iv < jv
1008 }
1009 if iv, jv := l.Info.StartLine, r.Info.StartLine; iv != jv {
1010 return iv < jv
1011 }
1012 return compareNodes(l, r)
1013 },
1014 }
1015 case AddressOrder:

Callers 10

printSourceFunction · 0.95
SortTagsFunction · 0.45
SortNodesMethod · 0.45
RemoveRedundantEdgesMethod · 0.45
SortMethod · 0.45
splitIntoRangesMethod · 0.45
PrintAssemblyFunction · 0.45
annotateAssemblyFunction · 0.45
printCallgrindFunction · 0.45
printTreeFunction · 0.45

Calls 4

compareNodesFunction · 0.85
entropyScoreFunction · 0.85
comparePrintableNameMethod · 0.80
abs64Function · 0.70

Tested by

no test coverage detected