本文整理匯總了Golang中cmd/pprof/internal/profile.Profile.Empty方法的典型用法代碼示例。如果您正苦於以下問題:Golang Profile.Empty方法的具體用法?Golang Profile.Empty怎麽用?Golang Profile.Empty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cmd/pprof/internal/profile.Profile
的用法示例。
在下文中一共展示了Profile.Empty方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: generate
func generate(interactive bool, prof *profile.Profile, obj plugin.ObjTool, ui plugin.UI, f *flags) error {
o, postProcess, err := parseOptions(f)
if err != nil {
return err
}
var w io.Writer
if *f.flagOutput == "" {
w = os.Stdout
} else {
ui.PrintErr("Generating report in ", *f.flagOutput)
outputFile, err := os.Create(*f.flagOutput)
if err != nil {
return err
}
defer outputFile.Close()
w = outputFile
}
if prof.Empty() {
return fmt.Errorf("profile is empty")
}
value, stype, unit := sampleFormat(prof, f)
o.SampleType = stype
rpt := report.New(prof, *o, value, unit)
// Do not apply filters if we're just generating a proto, so we
// still have all the data.
if o.OutputFormat != report.Proto {
// Delay applying focus/ignore until after creating the report so
// the report reflects the total number of samples.
if err := preprocess(prof, ui, f); err != nil {
return err
}
}
if postProcess == nil {
return report.Generate(w, rpt, obj)
}
var dot bytes.Buffer
if err = report.Generate(&dot, rpt, obj); err != nil {
return err
}
return postProcess(&dot, w, ui)
}