func buildFlameGraphElements()

in pkg/display/graph/flamegraph/flamegraph.go [120:141]


func buildFlameGraphElements(trees []*ProfilingDataTree) (result []*StackElement, maxDepth int64) {
	// adding the root element
	root := &StackElement{Symbol: "all"}
	result = append(result, root)

	// build elements
	var left int64
	for _, t := range trees {
		result, left = buildFlameGraphChildElements(result, t.Elements, nil, left)
	}

	// calculate the root total count
	for _, r := range result {
		if r.ParentID == "0" {
			root.Count += r.Count
		}
		if maxDepth < r.Depth {
			maxDepth = r.Depth
		}
	}
	return result, maxDepth
}