go 1.24
require (
- github.com/google/pprof v0.0.0-20240528025155-186aa0362fba
+ github.com/google/pprof v0.0.0-20240722153945-304e4f0156b8
golang.org/x/arch v0.8.1-0.20240716161256-b863392466ea
golang.org/x/build v0.0.0-20240722200705-b9910f320300
golang.org/x/mod v0.19.1-0.20240718175220-b56a28f8bd83
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
-github.com/google/pprof v0.0.0-20240528025155-186aa0362fba h1:ql1qNgCyOB7iAEk8JTNM+zJrgIbnyCKX/wdlyPufP5g=
-github.com/google/pprof v0.0.0-20240528025155-186aa0362fba/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo=
+github.com/google/pprof v0.0.0-20240722153945-304e4f0156b8 h1:ssNFCCVmib/GQSzx3uCWyfMgOamLGWuGqlMS77Y1m3Y=
+github.com/google/pprof v0.0.0-20240722153945-304e4f0156b8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo=
github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465 h1:KwWnWVWCNtNq/ewIX7HIKnELmEx2nDP42yskD/pi7QE=
github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68=
}
#detailsbox {
display: none;
- z-index: 1;
position: fixed;
top: 40px;
right: 20px;
}
.submenu {
display: none;
- z-index: 1;
margin-top: -4px;
min-width: 10em;
position: absolute;
top: 60px;
left: 50%;
transform: translateX(-50%);
-
- z-index: 3;
font-size: 125%;
background-color: #ffffff;
box-shadow: 0 1px 5px rgba(0,0,0,.3);
background-color: #ebf5fb;
font-weight: bold;
}
+/* stacking order */
+.boxtext { z-index: 2; } /* flame graph box text */
+#current-details { z-index: 2; } /* flame graph current box info */
+#detailsbox { z-index: 3; } /* profile details */
+.submenu { z-index: 4; }
+.dialog { z-index: 5; }
position: absolute;
top: 5px;
right: 5px;
- z-index: 2;
font-size: 12pt;
}
/* Background of a single flame-graph frame */
font-size: 12pt;
font-weight: bold;
}
-/* Ensure that pprof menu is above boxes */
-.submenu { z-index: 3; }
/* Right-click menu */
#action-menu {
max-width: 15em;
r.appendChild(t);
}
- r.addEventListener('click', () => { switchPivots(pprofQuoteMeta(src.UniqueName)); });
+ onClick(r, () => { switchPivots(pprofQuoteMeta(src.UniqueName)); });
r.addEventListener('mouseenter', () => { handleEnter(box, r); });
r.addEventListener('mouseleave', () => { handleLeave(box); });
r.addEventListener('contextmenu', (e) => { showActionMenu(e, box); });
return r;
}
+ // Handle clicks, but only if the mouse did not move during the click.
+ function onClick(target, handler) {
+ // Disable click if mouse moves more than threshold pixels since mousedown.
+ const threshold = 3;
+ let [x, y] = [-1, -1];
+ target.addEventListener('mousedown', (e) => {
+ [x, y] = [e.clientX, e.clientY];
+ });
+ target.addEventListener('click', (e) => {
+ if (Math.abs(e.clientX - x) <= threshold &&
+ Math.abs(e.clientY - y) <= threshold) {
+ handler();
+ }
+ });
+ }
+
function drawSep(y, posTotal, negTotal) {
const m = document.createElement('div');
m.innerText = summary(posTotal, negTotal);
"net/http"
"github.com/google/pprof/internal/measurement"
- "github.com/google/pprof/internal/report"
)
// stackView generates the flamegraph view.
}
nodes[0] = "" // root is not a real node
- _, legend := report.TextItems(rpt)
- ui.render(w, req, "stacks", rpt, errList, legend, webArgs{
+ ui.render(w, req, "stacks", rpt, errList, stacks.Legend(), webArgs{
Stacks: template.JS(b),
Nodes: nodes,
UnitDefs: measurement.UnitTypes,
func TextItems(rpt *Report) ([]TextItem, []string) {
g, origCount, droppedNodes, _ := rpt.newTrimmedGraph()
rpt.selectOutputUnit(g)
- labels := reportLabels(rpt, g, origCount, droppedNodes, 0, false)
+ labels := reportLabels(rpt, graphTotal(g), len(g.Nodes), origCount, droppedNodes, 0, false)
var items []TextItem
var flatSum int64
g, origCount, droppedNodes, _ := rpt.newTrimmedGraph()
rpt.selectOutputUnit(g)
- fmt.Fprintln(w, strings.Join(reportLabels(rpt, g, origCount, droppedNodes, 0, false), "\n"))
+ fmt.Fprintln(w, strings.Join(reportLabels(rpt, graphTotal(g), len(g.Nodes), origCount, droppedNodes, 0, false), "\n"))
fmt.Fprintln(w, separator)
fmt.Fprintln(w, legend)
func GetDOT(rpt *Report) (*graph.Graph, *graph.DotConfig) {
g, origCount, droppedNodes, droppedEdges := rpt.newTrimmedGraph()
rpt.selectOutputUnit(g)
- labels := reportLabels(rpt, g, origCount, droppedNodes, droppedEdges, true)
+ labels := reportLabels(rpt, graphTotal(g), len(g.Nodes), origCount, droppedNodes, droppedEdges, true)
c := &graph.DotConfig{
Title: rpt.options.Title,
return label
}
+func graphTotal(g *graph.Graph) int64 {
+ var total int64
+ for _, n := range g.Nodes {
+ total += n.FlatValue()
+ }
+ return total
+}
+
// reportLabels returns printable labels for a report. Includes
// profileLabels.
-func reportLabels(rpt *Report, g *graph.Graph, origCount, droppedNodes, droppedEdges int, fullHeaders bool) []string {
+func reportLabels(rpt *Report, shownTotal int64, nodeCount, origCount, droppedNodes, droppedEdges int, fullHeaders bool) []string {
nodeFraction := rpt.options.NodeFraction
edgeFraction := rpt.options.EdgeFraction
- nodeCount := len(g.Nodes)
var label []string
if len(rpt.options.ProfileLabels) > 0 {
label = ProfileLabels(rpt)
}
- var flatSum int64
- for _, n := range g.Nodes {
- flatSum = flatSum + n.FlatValue()
- }
-
if len(rpt.options.ActiveFilters) > 0 {
activeFilters := legendActiveFilters(rpt.options.ActiveFilters)
label = append(label, activeFilters...)
}
- label = append(label, fmt.Sprintf("Showing nodes accounting for %s, %s of %s total", rpt.formatValue(flatSum), strings.TrimSpace(measurement.Percentage(flatSum, rpt.total)), rpt.formatValue(rpt.total)))
+ label = append(label, fmt.Sprintf("Showing nodes accounting for %s, %s of %s total", rpt.formatValue(shownTotal), strings.TrimSpace(measurement.Percentage(shownTotal, rpt.total)), rpt.formatValue(rpt.total)))
if rpt.total != 0 {
if droppedNodes > 0 {
Unit string // One of "B", "s", "GCU", or "" (if unknown)
Stacks []Stack // List of stored stacks
Sources []StackSource // Mapping from source index to info
+ report *Report
}
// Stack holds a single stack instance.
Unit: unit,
Stacks: []Stack{}, // Ensure non-nil
Sources: []StackSource{}, // Ensure non-nil
+ report: rpt,
}
s.makeInitialStacks(rpt)
s.fillPlaces()
s.Sources[i].Color = int(index % numColors)
}
}
+
+// Legend returns the list of lines to display as the legend.
+func (s *StackSet) Legend() []string {
+ return reportLabels(s.report, s.report.total, len(s.Sources), len(s.Sources), 0, 0, false)
+}
-# github.com/google/pprof v0.0.0-20240528025155-186aa0362fba
+# github.com/google/pprof v0.0.0-20240722153945-304e4f0156b8
## explicit; go 1.19
github.com/google/pprof/driver
github.com/google/pprof/internal/binutils