本文整理匯總了Golang中github.com/google/pprof/profile.Profile.Copy方法的典型用法代碼示例。如果您正苦於以下問題:Golang Profile.Copy方法的具體用法?Golang Profile.Copy怎麽用?Golang Profile.Copy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/pprof/profile.Profile
的用法示例。
在下文中一共展示了Profile.Copy方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: generateReport
func generateReport(p *profile.Profile, cmd []string, vars variables, o *plugin.Options) error {
p = p.Copy() // Prevent modification to the incoming profile.
var w io.Writer
switch output := vars["output"].value; output {
case "":
w = os.Stdout
default:
o.UI.PrintErr("Generating report in ", output)
outputFile, err := o.Writer.Open(output)
if err != nil {
return err
}
defer outputFile.Close()
w = outputFile
}
vars = applyCommandOverrides(cmd, vars)
// Delay focus after configuring report to get percentages on all samples.
relative := vars["relative_percentages"].boolValue()
if relative {
if err := applyFocus(p, vars, o.UI); err != nil {
return err
}
}
ropt, err := reportOptions(p, vars)
if err != nil {
return err
}
c := pprofCommands[cmd[0]]
if c == nil {
panic("unexpected nil command")
}
ropt.OutputFormat = c.format
post := c.postProcess
if len(cmd) == 2 {
s, err := regexp.Compile(cmd[1])
if err != nil {
return fmt.Errorf("parsing argument regexp %s: %v", cmd[1], err)
}
ropt.Symbol = s
}
rpt := report.New(p, ropt)
if !relative {
if err := applyFocus(p, vars, o.UI); err != nil {
return err
}
}
if err := aggregate(p, vars); err != nil {
return err
}
if post == nil {
return report.Generate(w, rpt, o.Obj)
}
// Capture output into buffer and send to postprocessing command.
buf := &bytes.Buffer{}
if err := report.Generate(buf, rpt, o.Obj); err != nil {
return err
}
return post(buf.Bytes(), w, o.UI)
}