Documentation ¶
Overview ¶
Package profiling provides support for enabling profiling of command line tools via flags.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsPredefined ¶
IsPredefined returns true if the specified name is one of the pprof predefined profiles, or 'cpu' which is recognised by this package as requesting a cpu profile.
func PredefinedProfiles ¶
func PredefinedProfiles() []string
PredefinedProfiles returns the list of predefined profiles, ie. those documented as 'predefined' by the runtime/pprof package, such as "goroutine", "heap", "allocs", "threadcreate", "block", "mutex".
func Start ¶
Start enables the named profile and returns a function that can be used to save its contents to the specified file. Typical usage is as follows:
save, err := profiling.Start("cpu", "cpu.out") if err != nil { panic(err) } defer save()
For a heap profile simply use Start("heap", "heap.out"). Note that the returned save function cannot be used more than once and that Start must be called multiple times to create multiple heap output files for example. All of the predefined named profiles from runtime/pprof are supported. If a new, custom profile is requested, then the caller must obtain a reference to it via pprof.Lookup and the create profiling records appropriately.
func StartFromSpecs ¶
func StartFromSpecs(specs ...ProfileSpec) (func(), error)
StartFromSpecs starts all of the specified profiles.
Types ¶
type ProfileFlag ¶
type ProfileFlag struct {
Profiles []ProfileSpec
}
ProfileFlag can be used to represent flags to request arbritrary profiles.
type ProfileSpec ¶
ProfileSpec represents a named profile and the name of the file to write its contents to. CPU profiling can be requested using the name 'cpu' rather than the CPUProfiling API calls in runtime/pprof that predate the named profiles.