MCPcopy Create free account
hub / github.com/google/pprof / generateReport

Function generateReport

internal/driver/driver.go:114–164  ·  view source on GitHub ↗

generateReport is allowed to modify p.

(p *profile.Profile, cmd []string, cfg config, o *plugin.Options)

Source from the content-addressed store, hash-verified

112
113// generateReport is allowed to modify p.
114func generateReport(p *profile.Profile, cmd []string, cfg config, o *plugin.Options) error {
115 c, rpt, err := generateRawReport(p, cmd, cfg, o)
116 if err != nil {
117 return err
118 }
119
120 // Generate the report.
121 dst := new(bytes.Buffer)
122 switch rpt.OutputFormat() {
123 case report.WebList:
124 // We need template expansion, so generate here instead of in report.
125 err = printWebList(dst, rpt, o.Obj)
126 default:
127 err = report.Generate(dst, rpt, o.Obj)
128 }
129 if err != nil {
130 return err
131 }
132 src := dst
133
134 // If necessary, perform any data post-processing.
135 if c.postProcess != nil {
136 dst = new(bytes.Buffer)
137 if err := c.postProcess(src, dst, o.UI); err != nil {
138 return err
139 }
140 src = dst
141 }
142
143 // If no output is specified, use default visualizer.
144 output := cfg.Output
145 if output == "" {
146 if c.visualizer != nil {
147 return c.visualizer(src, os.Stdout, o.UI)
148 }
149 _, err := src.WriteTo(os.Stdout)
150 return err
151 }
152
153 // Output to specified file.
154 o.UI.PrintErr("Generating report in ", output)
155 out, err := o.Writer.Open(output)
156 if err != nil {
157 return err
158 }
159 if _, err := src.WriteTo(out); err != nil {
160 out.Close()
161 return err
162 }
163 return out.Close()
164}
165
166func printWebList(dst io.Writer, rpt *report.Report, obj plugin.ObjTool) error {
167 listing, err := report.MakeWebList(rpt, obj, -1)

Callers 1

PProfFunction · 0.85

Calls 7

GenerateFunction · 0.92
generateRawReportFunction · 0.85
printWebListFunction · 0.85
OutputFormatMethod · 0.80
PrintErrMethod · 0.65
OpenMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…