// See the License for the specific language governing permissions and
// limitations under the License.
-// Package graph collects a set of samples into a directed graph.
-
-// Original file location: https://github.com/google/pprof/tree/main/internal/graph/graph.go
-package pgo
+// Package graph represents a pprof profile as a directed graph.
+//
+// This package is a simplified fork of github.com/google/pprof/internal/graph.
+package graph
import (
"fmt"
return e.Weight / e.WeightDiv
}
-// newGraph computes a graph from a profile.
-func newGraph(prof *profile.Profile, o *Options) *Graph {
+// NewGraph computes a graph from a profile.
+func NewGraph(prof *profile.Profile, o *Options) *Graph {
nodes, locationMap := CreateNodes(prof, o)
seenNode := make(map[*Node]bool)
seenEdge := make(map[nodePair]bool)
import (
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
+ "cmd/compile/internal/pgo/internal/graph"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"fmt"
return nil, fmt.Errorf(`profile does not contain a sample index with value/type "samples/count" or cpu/nanoseconds"`)
}
- g := newGraph(profile, &Options{
+ g := graph.NewGraph(profile, &graph.Options{
CallTree: false,
SampleValue: func(v []int64) int64 { return v[valueIndex] },
})
// create edges for WeightedCG.
//
// Caller should ignore the profile if p.TotalNodeWeight == 0 || p.TotalEdgeWeight == 0.
-func (p *Profile) processprofileGraph(g *Graph) error {
+func (p *Profile) processprofileGraph(g *graph.Graph) error {
nFlat := make(map[string]int64)
nCum := make(map[string]int64)
seenStartLine := false