ソースを参照

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,9 +149,14 @@ func greetings(p *profile.Profile, ui plugin.UI) {
149 149
 	numLabelUnits := identifyNumLabelUnits(p, ui)
150 150
 	ropt, err := reportOptions(p, numLabelUnits, pprofVariables)
151 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 162
 // shortcuts represents composite commands that expand into a sequence