本文整理汇总了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)
}