瀏覽代碼

internal/driver: suggest sample_index in case empty default samples (#336)

In the interactive mode, inform users of different sample types
if the profile includes zero samples for selected sample type
by default (or through user-provided sample_index flag value).

The example output may look like

$ pprof mem.prof
Type: inuse_space
Time: Mar 20, 2018 at 11:36am (EDT)

No samples were found with the default sample value type.
Try "sample_index" command to analyze different sample values.

Entering interactive mode (type "help" for commands, "o" for options)
(pprof)

Update golang/go#24443
Hyang-Ah Hana Kim 7 年之前
父節點
當前提交
a74ae6fb3c
共有 1 個檔案被更改,包括 7 行新增2 行删除
  1. 7
    2
      internal/driver/interactive.go

+ 7
- 2
internal/driver/interactive.go 查看文件

149
 	numLabelUnits := identifyNumLabelUnits(p, ui)
149
 	numLabelUnits := identifyNumLabelUnits(p, ui)
150
 	ropt, err := reportOptions(p, numLabelUnits, pprofVariables)
150
 	ropt, err := reportOptions(p, numLabelUnits, pprofVariables)
151
 	if err == nil {
151
 	if err == nil {
152
-		ui.Print(strings.Join(report.ProfileLabels(report.New(p, ropt)), "\n"))
152
+		rpt := report.New(p, ropt)
153
+		ui.Print(strings.Join(report.ProfileLabels(rpt), "\n"))
154
+		if rpt.Total() == 0 && len(p.SampleType) > 1 {
155
+			ui.Print(`No samples were found with the default sample value type.`)
156
+			ui.Print(`Try "sample_index" command to analyze different sample values.`, "\n")
157
+		}
153
 	}
158
 	}
154
-	ui.Print("Entering interactive mode (type \"help\" for commands, \"o\" for options)")
159
+	ui.Print(`Entering interactive mode (type "help" for commands, "o" for options)`)
155
 }
160
 }
156
 
161
 
157
 // shortcuts represents composite commands that expand into a sequence
162
 // shortcuts represents composite commands that expand into a sequence