浏览代码

Merge pull request #22 from wade-k/fix_report_label

Makes the report label accurate
Raul Silvera 8 年前
父节点
当前提交
1519400cef

+ 1
- 1
internal/driver/testdata/pprof.cpusmall.flat.addresses.tree 查看文件

1
 Showing nodes accounting for 4s, 100% of 4s total
1
 Showing nodes accounting for 4s, 100% of 4s total
2
-Showing top 4 nodes out of 5 (cum >= 2s)
2
+Showing top 4 nodes out of 5
3
 ----------------------------------------------------------+-------------
3
 ----------------------------------------------------------+-------------
4
       flat  flat%   sum%        cum   cum%   calls calls% + context 	 	 
4
       flat  flat%   sum%        cum   cum%   calls calls% + context 	 	 
5
 ----------------------------------------------------------+-------------
5
 ----------------------------------------------------------+-------------

+ 3
- 4
internal/report/report.go 查看文件

798
 func reportLabels(rpt *Report, g *graph.Graph, origCount, droppedNodes, droppedEdges int, fullHeaders bool) []string {
798
 func reportLabels(rpt *Report, g *graph.Graph, origCount, droppedNodes, droppedEdges int, fullHeaders bool) []string {
799
 	nodeFraction := rpt.options.NodeFraction
799
 	nodeFraction := rpt.options.NodeFraction
800
 	edgeFraction := rpt.options.EdgeFraction
800
 	edgeFraction := rpt.options.EdgeFraction
801
-	nodeCount := rpt.options.NodeCount
801
+	nodeCount := len(g.Nodes)
802
 
802
 
803
 	var label []string
803
 	var label []string
804
 	if len(rpt.options.ProfileLabels) > 0 {
804
 	if len(rpt.options.ProfileLabels) > 0 {
826
 				rpt.formatValue(abs64(int64(float64(rpt.total)*edgeFraction)))))
826
 				rpt.formatValue(abs64(int64(float64(rpt.total)*edgeFraction)))))
827
 		}
827
 		}
828
 		if nodeCount > 0 && nodeCount < origCount {
828
 		if nodeCount > 0 && nodeCount < origCount {
829
-			label = append(label, fmt.Sprintf("Showing top %d nodes out of %d (cum >= %s)",
830
-				nodeCount, origCount,
831
-				rpt.formatValue(g.Nodes[len(g.Nodes)-1].Cum)))
829
+			label = append(label, fmt.Sprintf("Showing top %d nodes out of %d",
830
+				nodeCount, origCount))
832
 		}
831
 		}
833
 	}
832
 	}
834
 	return label
833
 	return label

+ 0
- 55
profile/testdata/cppbench.svg 查看文件

1
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
3
- "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
-<!-- Generated by graphviz version 2.36.0 (20140111.2315)
5
- -->
6
-<!-- Title: cppbench_server_main Pages: 1 -->
7
-<svg width="555pt" height="210pt"
8
- viewBox="0.00 0.00 555.00 210.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
9
-<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 206)">
10
-<title>cppbench_server_main</title>
11
-<polygon fill="white" stroke="none" points="-4,4 -4,-206 551,-206 551,4 -4,4"/>
12
-<g id="clust1" class="cluster"><title>cluster_L</title>
13
-<polygon fill="none" stroke="black" points="8,-80 8,-194 402,-194 402,-80 8,-80"/>
14
-</g>
15
-<!-- File: cppbench_server_main -->
16
-<g id="node1" class="node"><title>File: cppbench_server_main</title>
17
-<polygon fill="#f8f8f8" stroke="black" points="394.25,-186 15.75,-186 15.75,-88 394.25,-88 394.25,-186"/>
18
-<text text-anchor="start" x="23.5" y="-169.2" font-family="Times,serif" font-size="16.00">File: cppbench_server_main</text>
19
-<text text-anchor="start" x="23.5" y="-151.2" font-family="Times,serif" font-size="16.00">Type: cpu</text>
20
-<text text-anchor="start" x="23.5" y="-133.2" font-family="Times,serif" font-size="16.00">0 of 7120000000ns total (0%)</text>
21
-<text text-anchor="start" x="23.5" y="-115.2" font-family="Times,serif" font-size="16.00">Dropped 56 nodes (cum &lt;= 35600000ns)</text>
22
-<text text-anchor="start" x="23.5" y="-97.2" font-family="Times,serif" font-size="16.00">Showing top 2 nodes out of 38 (cum &gt;= 7070000000ns)</text>
23
-</g>
24
-<!-- N1 -->
25
-<g id="node2" class="node"><title>N1</title>
26
-<g id="a_node2"><a xlink:title="start_thread (7120000000ns)">
27
-<polygon fill="#f8f8f8" stroke="black" points="513,-155 413,-155 413,-119 513,-119 513,-155"/>
28
-<text text-anchor="middle" x="463" y="-139.6" font-family="Times,serif" font-size="8.00">start_thread</text>
29
-<text text-anchor="middle" x="463" y="-130.6" font-family="Times,serif" font-size="8.00">0 of 7120000000ns(100%)</text>
30
-</a>
31
-</g>
32
-</g>
33
-<!-- N2 -->
34
-<g id="node3" class="node"><title>N2</title>
35
-<g id="a_node3"><a xlink:title="RunWorkerLoop (7070000000ns)">
36
-<polygon fill="#f8f8f8" stroke="black" points="515.5,-36 410.5,-36 410.5,-0 515.5,-0 515.5,-36"/>
37
-<text text-anchor="middle" x="463" y="-20.6" font-family="Times,serif" font-size="8.00">RunWorkerLoop</text>
38
-<text text-anchor="middle" x="463" y="-11.6" font-family="Times,serif" font-size="8.00">0 of 7070000000ns(99.30%)</text>
39
-</a>
40
-</g>
41
-</g>
42
-<!-- N1&#45;&gt;N2 -->
43
-<g id="edge1" class="edge"><title>N1&#45;&gt;N2</title>
44
-<g id="a_edge1"><a xlink:title="start_thread ... RunWorkerLoop (7070000000ns)">
45
-<path fill="none" stroke="black" stroke-width="5" stroke-dasharray="1,5" d="M463,-118.987C463,-99.9242 463,-68.7519 463,-46.2768"/>
46
-<polygon fill="black" stroke="black" stroke-width="5" points="467.375,-46.0333 463,-36.0333 458.625,-46.0334 467.375,-46.0333"/>
47
-</a>
48
-</g>
49
-<g id="a_edge1&#45;label"><a xlink:title="start_thread ... RunWorkerLoop (7070000000ns)">
50
-<text text-anchor="middle" x="505" y="-58.3" font-family="Times,serif" font-size="14.00"> 7070000000ns</text>
51
-</a>
52
-</g>
53
-</g>
54
-</g>
55
-</svg>