Debian Codegraph @

internal/graph/dotgraph.go

raw symbols SCIP
1 // Copyright 2014 Google Inc. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/
16
17 import (
18 "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/"
19 "ioscip-go gomod github.com/golang/go/src go1.24.0 io/"
20 "mathscip-go gomod github.com/golang/go/src go1.24.0 math/"
21 "path/filepathscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/"
22 "stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/"
23
24 "github.com/google/pprof/internal/measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/"
25 )
26
27 // DotAttributes contains details about the graph itself, giving
28 // insight into how its elements should be rendered.
29 type DotAttributesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotAttributes# struct {
30 Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotAttributes#Nodes. map[*Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#]*DotNodeAttributesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotNodeAttributes# // A map allowing each Node to have its own visualization option
31 }
32
33 // DotNodeAttributes contains Node specific visualization options.
34 type DotNodeAttributesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotNodeAttributes# struct {
35 Shapescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotNodeAttributes#Shape. string // The optional shape of the node when rendered visually
36 Boldscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotNodeAttributes#Bold. bool // If the node should be bold or not
37 Peripheriesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotNodeAttributes#Peripheries. int // An optional number of borders to place around a node
38 URLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotNodeAttributes#URL. string // An optional url link to add to a node
39 Formatterscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotNodeAttributes#Formatter. func(*NodeInfoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#) string // An optional formatter for the node's label
40 }
41
42 // DotConfig contains attributes about how a graph should be
43 // constructed and how it should look.
44 type DotConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig# struct {
45 Titlescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Title. string // The title of the DOT graph
46 LegendURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#LegendURL. string // The URL to link to from the legend.
47 Labelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Labels. []string // The labels for the DOT's legend
48
49 FormatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#FormatValue. func(int64) string // A formatting function for values
50 Totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Total. int64 // The total weight of the graph, used to compute percentages
51 }
52
53 const maxNodeletsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/maxNodelets. = 4 // Number of nodelets for labels (both numeric and non)
54
55 // ComposeDot creates and writes a in the DOT format to the writer, using
56 // the configurations given.
57 func ComposeDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/ComposeDot().(w ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Writerscip-go gomod github.com/golang/go/src go1.24.0 io/Writer#, g *Graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#, a *DotAttributesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotAttributes#, c *DotConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#) {
58 builder := &builderscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#{w, a, c}
59
60 // Begin constructing DOT by adding a title and legend.
61 builder.startscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#start().()
62 defer builder.finishscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#finish().()
63 builder.addLegendscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#addLegend().()
64
65 if len(g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes.) == 0 {
66 return
67 }
68
69 // Preprocess graph to get id map and find max flat.
70 nodeIDMap := make(map[*Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#]int)
71 hasNodelets := make(map[*Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#]bool)
72
73 maxFlat := float64(abs64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/abs64().(g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes.[0].FlatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#FlatValue().()))
74 for i, n := range g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes. {
75 nodeIDMap[n] = i + 1
76 if float64(abs64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/abs64().(n.FlatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#FlatValue().())) > maxFlat {
77 maxFlat = float64(abs64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/abs64().(n.FlatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#FlatValue().()))
78 }
79 }
80
81 edges := EdgeMapscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/EdgeMap#{}
82
83 // Add nodes and nodelets to DOT builder.
84 for _, n := range g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes. {
85 builder.addNodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#addNode().(n, nodeIDMap[n], maxFlat)
86 hasNodelets[n] = builder.addNodeletsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#addNodelets().(n, nodeIDMap[n])
87
88 // Collect all edges. Use a fake node to support multiple incoming edges.
89 for _, e := range n.Outscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Out. {
90 edges[&Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#{}] = e
91 }
92 }
93
94 // Add edges to DOT builder. Sort edges by frequency as a hint to the graph layout engine.
95 for _, e := range edges.Sortscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/EdgeMap#Sort().() {
96 builder.addEdgescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#addEdge().(e, nodeIDMap[e.Srcscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Src.], nodeIDMap[e.Destscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Dest.], hasNodelets[e.Srcscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Src.])
97 }
98 }
99
100 // builder wraps an io.Writer and understands how to compose DOT formatted elements.
101 type builderscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder# struct {
102 ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Writerscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#Writer.
103 attributesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#attributes. *DotAttributesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotAttributes#
104 configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config. *DotConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#
105 }
106
107 // start generates a title and initial node in DOT format.
108 func (b *builderscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#) startscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#start().() {
109 graphname := "unnamed"
110 if b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..Titlescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Title. != "" {
111 graphname = b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..Titlescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Title.
112 }
113 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(b, `digraph "`+graphname+`" {`)
114 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(b, `node [style=filled fillcolor="#f8f8f8"]`)
115 }
116
117 // finish closes the opening curly bracket in the constructed DOT buffer.
118 func (b *builderscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#) finishscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#finish().() {
119 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(b, "}")
120 }
121
122 // addLegend generates a legend in DOT format.
123 func (b *builderscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#) addLegendscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#addLegend().() {
124 labels := b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..Labelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Labels.
125 if len(labels) == 0 {
126 return
127 }
128 title := labels[0]
129 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(b, `subgraph cluster_L { "%s" [shape=box fontsize=16`, escapeForDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/escapeForDot().(title))
130 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(b, ` label="%s\l"`, stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.24.0 strings/Join().(escapeAllForDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/escapeAllForDot().(labels), `\l`))
131 if b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..LegendURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#LegendURL. != "" {
132 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(b, ` URL="%s" target="_blank"`, b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..LegendURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#LegendURL.)
133 }
134 if b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..Titlescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Title. != "" {
135 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(b, ` tooltip="%s"`, b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..Titlescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Title.)
136 }
137 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(b, "] }\n")
138 }
139
140 // addNode generates a graph node in DOT format.
141 func (b *builderscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#) addNodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#addNode().(node *Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#, nodeID int, maxFlat float64) {
142 flat, cum := node.FlatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#FlatValue().(), node.CumValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#CumValue().()
143 attrs := b.attributesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#attributes..Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotAttributes#Nodes.[node]
144
145 // Populate label for node.
146 var label string
147 if attrs != nil && attrs.Formatterscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotNodeAttributes#Formatter. != nil {
148 label = attrs.Formatterscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotNodeAttributes#Formatter.(&node.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info.)
149 } else {
150 label = multilinePrintableNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/multilinePrintableName().(&node.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info.)
151 }
152
153 flatValue := b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..FormatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#FormatValue.(flat)
154 if flat != 0 {
155 label = label + fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(`%s (%s)`,
156 flatValue,
157 stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.24.0 strings/TrimSpace().(measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Percentagescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Percentage().(flat, b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..Totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Total.)))
158 } else {
159 label = label + "0"
160 }
161 cumValue := flatValue
162 if cum != flat {
163 if flat != 0 {
164 label = label + `\n`
165 } else {
166 label = label + " "
167 }
168 cumValue = b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..FormatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#FormatValue.(cum)
169 label = label + fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(`of %s (%s)`,
170 cumValue,
171 stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.24.0 strings/TrimSpace().(measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Percentagescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Percentage().(cum, b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..Totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Total.)))
172 }
173
174 // Scale font sizes from 8 to 24 based on percentage of flat frequency.
175 // Use non linear growth to emphasize the size difference.
176 baseFontSize, maxFontGrowth := 8, 16.0
177 fontSize := baseFontSize
178 if maxFlat != 0 && flat != 0 && float64(abs64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/abs64().(flat)) <= maxFlat {
179 fontSize += int(mathscip-go gomod github.com/golang/go/src go1.24.0 math/.Ceilscip-go gomod github.com/golang/go/src go1.24.0 math/Ceil().(maxFontGrowth * mathscip-go gomod github.com/golang/go/src go1.24.0 math/.Sqrtscip-go gomod github.com/golang/go/src go1.24.0 math/Sqrt().(float64(abs64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/abs64().(flat))/maxFlat)))
180 }
181
182 // Determine node shape.
183 shape := "box"
184 if attrs != nil && attrs.Shapescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotNodeAttributes#Shape. != "" {
185 shape = attrs.Shapescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotNodeAttributes#Shape.
186 }
187
188 // Create DOT attribute for node.
189 attr := fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(`label="%s" id="node%d" fontsize=%d shape=%s tooltip="%s (%s)" color="%s" fillcolor="%s"`,
190 label, nodeID, fontSize, shape, escapeForDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/escapeForDot().(node.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..PrintableNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#PrintableName().()), cumValue,
191 dotColorscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/dotColor().(float64(node.CumValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#CumValue().())/float64(abs64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/abs64().(b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..Totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Total.)), false),
192 dotColorscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/dotColor().(float64(node.CumValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#CumValue().())/float64(abs64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/abs64().(b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..Totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Total.)), true))
193
194 // Add on extra attributes if provided.
195 if attrs != nil {
196 // Make bold if specified.
197 if attrs.Boldscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotNodeAttributes#Bold. {
198 attr += ` style="bold,filled"`
199 }
200
201 // Add peripheries if specified.
202 if attrs.Peripheriesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotNodeAttributes#Peripheries. != 0 {
203 attr += fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(` peripheries=%d`, attrs.Peripheriesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotNodeAttributes#Peripheries.)
204 }
205
206 // Add URL if specified. target="_blank" forces the link to open in a new tab.
207 if attrs.URLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotNodeAttributes#URL. != "" {
208 attr += fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(` URL="%s" target="_blank"`, attrs.URLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotNodeAttributes#URL.)
209 }
210 }
211
212 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(b, "N%d [%s]\n", nodeID, attr)
213 }
214
215 // addNodelets generates the DOT boxes for the node tags if they exist.
216 func (b *builderscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#) addNodeletsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#addNodelets().(node *Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#, nodeID int) bool {
217 var nodelets string
218
219 // Populate two Tag slices, one for LabelTags and one for NumericTags.
220 var ts []*Tagscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#
221 lnts := make(map[string][]*Tagscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#)
222 for _, t := range node.LabelTagsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#LabelTags. {
223 ts = append(ts, t)
224 }
225 for l, tm := range node.NumericTagsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#NumericTags. {
226 for _, t := range tm {
227 lnts[l] = append(lnts[l], t)
228 }
229 }
230
231 // For leaf nodes, print cumulative tags (includes weight from
232 // children that have been deleted).
233 // For internal nodes, print only flat tags.
234 flatTags := len(node.Outscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Out.) > 0
235
236 // Select the top maxNodelets alphanumeric labels by weight.
237 SortTagsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/SortTags().(ts, flatTags)
238 if len(ts) > maxNodeletsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/maxNodelets. {
239 ts = ts[:maxNodeletsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/maxNodelets.]
240 }
241 for i, t := range ts {
242 w := t.CumValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#CumValue().()
243 if flatTags {
244 w = t.FlatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#FlatValue().()
245 }
246 if w == 0 {
247 continue
248 }
249 weight := b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..FormatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#FormatValue.(w)
250 nodelets += fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(`N%d_%d [label = "%s" id="N%d_%d" fontsize=8 shape=box3d tooltip="%s"]`+"\n", nodeID, i, t.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Name., nodeID, i, weight)
251 nodelets += fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(`N%d -> N%d_%d [label=" %s" weight=100 tooltip="%s" labeltooltip="%s"]`+"\n", nodeID, nodeID, i, weight, weight, weight)
252 if nts := lnts[t.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Name.]; nts != nil {
253 nodelets += b.numericNodeletsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#numericNodelets().(nts, maxNodeletsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/maxNodelets., flatTags, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(`N%d_%d`, nodeID, i))
254 }
255 }
256
257 if nts := lnts[""]; nts != nil {
258 nodelets += b.numericNodeletsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#numericNodelets().(nts, maxNodeletsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/maxNodelets., flatTags, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(`N%d`, nodeID))
259 }
260
261 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprint().(b, nodelets)
262 return nodelets != ""
263 }
264
265 func (b *builderscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#) numericNodeletsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#numericNodelets().(nts []*Tagscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#, maxNumNodelets int, flatTags bool, source string) string {
266 nodelets := ""
267
268 // Collapse numeric labels into maxNumNodelets buckets, of the form:
269 // 1MB..2MB, 3MB..5MB, ...
270 for j, t := range b.collapsedTagsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#collapsedTags().(nts, maxNumNodelets, flatTags) {
271 w, attr := t.CumValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#CumValue().(), ` style="dotted"`
272 if flatTags || t.FlatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#FlatValue().() == t.CumValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#CumValue().() {
273 w, attr = t.FlatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#FlatValue().(), ""
274 }
275 if w != 0 {
276 weight := b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..FormatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#FormatValue.(w)
277 nodelets += fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(`N%s_%d [label = "%s" id="N%s_%d" fontsize=8 shape=box3d tooltip="%s"]`+"\n", source, j, t.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Name., source, j, weight)
278 nodelets += fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(`%s -> N%s_%d [label=" %s" weight=100 tooltip="%s" labeltooltip="%s"%s]`+"\n", source, source, j, weight, weight, weight, attr)
279 }
280 }
281 return nodelets
282 }
283
284 // addEdge generates a graph edge in DOT format.
285 func (b *builderscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#) addEdgescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#addEdge().(edge *Edgescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#, from, to int, hasNodelets bool) {
286 var inline string
287 if edge.Inlinescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Inline. {
288 inline = `\n (inline)`
289 }
290 w := b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..FormatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#FormatValue.(edge.WeightValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#WeightValue().())
291 attr := fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(`label=" %s%s"`, w, inline)
292 if b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..Totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Total. != 0 {
293 // Note: edge.weight > b.config.Total is possible for profile diffs.
294 if weight := 1 + int(min64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/min64().(abs64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/abs64().(edge.WeightValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#WeightValue().()*100/b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..Totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Total.), 100)); weight > 1 {
295 attr = fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(`%s weight=%d`, attr, weight)
296 }
297 if width := 1 + int(min64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/min64().(abs64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/abs64().(edge.WeightValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#WeightValue().()*5/b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..Totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Total.), 5)); width > 1 {
298 attr = fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(`%s penwidth=%d`, attr, width)
299 }
300 attr = fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(`%s color="%s"`, attr,
301 dotColorscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/dotColor().(float64(edge.WeightValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#WeightValue().())/float64(abs64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/abs64().(b.configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#config..Totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Total.)), false))
302 }
303 arrow := "->"
304 if edge.Residualscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Residual. {
305 arrow = "..."
306 }
307 tooltip := fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(`"%s %s %s (%s)"`,
308 escapeForDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/escapeForDot().(edge.Srcscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Src..Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..PrintableNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#PrintableName().()), arrow,
309 escapeForDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/escapeForDot().(edge.Destscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Dest..Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..PrintableNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#PrintableName().()), w)
310 attr = fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(`%s tooltip=%s labeltooltip=%s`, attr, tooltip, tooltip)
311
312 if edge.Residualscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Residual. {
313 attr = attr + ` style="dotted"`
314 }
315
316 if hasNodelets {
317 // Separate children further if source has tags.
318 attr = attr + " minlen=2"
319 }
320
321 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(b, "N%d -> N%d [%s]\n", from, to, attr)
322 }
323
324 // dotColor returns a color for the given score (between -1.0 and
325 // 1.0), with -1.0 colored green, 0.0 colored grey, and 1.0 colored
326 // red. If isBackground is true, then a light (low-saturation)
327 // color is returned (suitable for use as a background color);
328 // otherwise, a darker color is returned (suitable for use as a
329 // foreground color).
330 func dotColorscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/dotColor().(score float64, isBackground bool) string {
331 // A float between 0.0 and 1.0, indicating the extent to which
332 // colors should be shifted away from grey (to make positive and
333 // negative values easier to distinguish, and to make more use of
334 // the color range.)
335 const shift = 0.7
336
337 // Saturation and value (in hsv colorspace) for background colors.
338 const bgSaturation = 0.1
339 const bgValue = 0.93
340
341 // Saturation and value (in hsv colorspace) for foreground colors.
342 const fgSaturation = 1.0
343 const fgValue = 0.7
344
345 // Choose saturation and value based on isBackground.
346 var saturation float64
347 var value float64
348 if isBackground {
349 saturation = bgSaturation
350 value = bgValue
351 } else {
352 saturation = fgSaturation
353 value = fgValue
354 }
355
356 // Limit the score values to the range [-1.0, 1.0].
357 score = mathscip-go gomod github.com/golang/go/src go1.24.0 math/.Maxscip-go gomod github.com/golang/go/src go1.24.0 math/Max().(-1.0, mathscip-go gomod github.com/golang/go/src go1.24.0 math/.Minscip-go gomod github.com/golang/go/src go1.24.0 math/Min().(1.0, score))
358
359 // Reduce saturation near score=0 (so it is colored grey, rather than yellow).
360 if mathscip-go gomod github.com/golang/go/src go1.24.0 math/.Absscip-go gomod github.com/golang/go/src go1.24.0 math/Abs().(score) < 0.2 {
361 saturation *= mathscip-go gomod github.com/golang/go/src go1.24.0 math/.Absscip-go gomod github.com/golang/go/src go1.24.0 math/Abs().(score) / 0.2
362 }
363
364 // Apply 'shift' to move scores away from 0.0 (grey).
365 if score > 0.0 {
366 score = mathscip-go gomod github.com/golang/go/src go1.24.0 math/.Powscip-go gomod github.com/golang/go/src go1.24.0 math/Pow().(score, (1.0 - shift))
367 }
368 if score < 0.0 {
369 score = -mathscip-go gomod github.com/golang/go/src go1.24.0 math/.Powscip-go gomod github.com/golang/go/src go1.24.0 math/Pow().(-score, (1.0 - shift))
370 }
371
372 var r, g, b float64 // red, green, blue
373 if score < 0.0 {
374 g = value
375 r = value * (1 + saturation*score)
376 } else {
377 r = value
378 g = value * (1 - saturation*score)
379 }
380 b = value * (1 - saturation)
381 return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("#%02x%02x%02x", uint8(r*255.0), uint8(g*255.0), uint8(b*255.0))
382 }
383
384 func multilinePrintableNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/multilinePrintableName().(info *NodeInfoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#) string {
385 infoCopy := *info
386 infoCopy.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name. = escapeForDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/escapeForDot().(ShortenFunctionNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/ShortenFunctionName().(infoCopy.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name.))
387 infoCopy.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name. = stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.24.0 strings/ReplaceAll().(infoCopy.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name., "::", `\n`)
388 // Go type parameters are reported as "[...]" by Go pprof profiles.
389 // Keep this ellipsis rather than replacing with newlines below.
390 infoCopy.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name. = stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.24.0 strings/ReplaceAll().(infoCopy.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name., "[...]", "[…]")
391 infoCopy.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name. = stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.24.0 strings/ReplaceAll().(infoCopy.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name., ".", `\n`)
392 if infoCopy.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#File. != "" {
393 infoCopy.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#File. = filepathscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/.Basescip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/Base().(infoCopy.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#File.)
394 }
395 return stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.24.0 strings/Join().(infoCopy.NameComponentsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#NameComponents().(), `\n`) + `\n`
396 }
397
398 // collapsedTags trims and sorts a slice of tags.
399 func (b *builderscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#) collapsedTagsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#collapsedTags().(ts []*Tagscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#, count int, flatTags bool) []*Tagscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag# {
400 ts = SortTagsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/SortTags().(ts, flatTags)
401 if len(ts) <= count {
402 return ts
403 }
404
405 tagGroups := make([][]*Tagscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#, count)
406 for i, t := range (ts)[:count] {
407 tagGroups[i] = []*Tagscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#{t}
408 }
409 for _, t := range (ts)[count:] {
410 g, d := 0, tagDistancescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/tagDistance().(t, tagGroups[0][0])
411 for i := 1; i < count; i++ {
412 if nd := tagDistancescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/tagDistance().(t, tagGroups[i][0]); nd < d {
413 g, d = i, nd
414 }
415 }
416 tagGroups[g] = append(tagGroups[g], t)
417 }
418
419 var nts []*Tagscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#
420 for _, g := range tagGroups {
421 l, w, c := b.tagGroupLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#tagGroupLabel().(g)
422 nts = append(nts, &Tagscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#{
423 Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Name.: l,
424 Flatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Flat.: w,
425 Cumscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Cum.: c,
426 })
427 }
428 return SortTagsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/SortTags().(nts, flatTags)
429 }
430
431 func tagDistancescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/tagDistance().(t, u *Tagscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#) float64 {
432 v, _ := measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Scalescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Scale().(u.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Value., u.Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Unit., t.Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Unit.)
433 if v < float64(t.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Value.) {
434 return float64(t.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Value.) - v
435 }
436 return v - float64(t.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Value.)
437 }
438
439 func (b *builderscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#) tagGroupLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/builder#tagGroupLabel().(g []*Tagscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#) (label string, flat, cum int64) {
440 if len(g) == 1 {
441 t := g[0]
442 return measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Label().(t.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Value., t.Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Unit.), t.FlatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#FlatValue().(), t.CumValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#CumValue().()
443 }
444 min := g[0]
445 max := g[0]
446 df, f := min.FlatDivscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#FlatDiv., min.Flatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Flat.
447 dc, c := min.CumDivscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#CumDiv., min.Cumscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Cum.
448 for _, t := range g[1:] {
449 if v, _ := measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Scalescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Scale().(t.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Value., t.Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Unit., min.Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Unit.); int64(v) < min.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Value. {
450 min = t
451 }
452 if v, _ := measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Scalescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Scale().(t.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Value., t.Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Unit., max.Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Unit.); int64(v) > max.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Value. {
453 max = t
454 }
455 f += t.Flatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Flat.
456 df += t.FlatDivscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#FlatDiv.
457 c += t.Cumscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Cum.
458 dc += t.CumDivscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#CumDiv.
459 }
460 if df != 0 {
461 f = f / df
462 }
463 if dc != 0 {
464 c = c / dc
465 }
466
467 // Tags are not scaled with the selected output unit because tags are often
468 // much smaller than other values which appear, so the range of tag sizes
469 // sometimes would appear to be "0..0" when scaled to the selected output unit.
470 return measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Label().(min.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Value., min.Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Unit.) + ".." + measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Label().(max.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Value., max.Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Unit.), f, c
471 }
472
473 func min64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/min64().(a, b int64) int64 {
474 if a < b {
475 return a
476 }
477 return b
478 }
479
480 // escapeAllForDot applies escapeForDot to all strings in the given slice.
481 func escapeAllForDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/escapeAllForDot().(in []string) []string {
482 var out = make([]string, len(in))
483 for i := range in {
484 out[i] = escapeForDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/escapeForDot().(in[i])
485 }
486 return out
487 }
488
489 // escapeForDot escapes double quotes and backslashes, and replaces Graphviz's
490 // "center" character (\n) with a left-justified character.
491 // See https://graphviz.org/docs/attr-types/escString/ for more info.
492 func escapeForDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/escapeForDot().(str string) string {
493 return stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.24.0 strings/ReplaceAll().(stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.24.0 strings/ReplaceAll().(stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.24.0 strings/ReplaceAll().(str, `\`, `\\`), `"`, `\"`), "\n", `\l`)
494 }