Lines Matching refs:Profile
21 // var cpuprofile = flag.String("cpuprofile", "", "write cpu profile `file`")
22 // var memprofile = flag.String("memprofile", "", "write memory profile to `file`")
29 // log.Fatal("could not create CPU profile: ", err)
32 // log.Fatal("could not start CPU profile: ", err)
40 // log.Fatal("could not create memory profile: ", err)
44 // log.Fatal("could not write memory profile: ", err)
76 "internal/pprof/profile"
90 // A Profile is a collection of stack traces showing the call sequences
96 // A Profile's methods can be called from multiple goroutines simultaneously.
98 // Each Profile has a unique name. A few profiles are predefined:
109 // The heap profile reports statistics as of the most recently completed
111 // the profile away from live data and toward garbage.
112 // If there has been no garbage collection at all, the heap profile reports
116 // The CPU profile is not available as a Profile. It has a special API,
120 type Profile struct {
131 m map[string]*Profile
134 var goroutineProfile = &Profile{
140 var threadcreateProfile = &Profile{
146 var heapProfile = &Profile{
152 var blockProfile = &Profile{
158 var mutexProfile = &Profile{
168 profiles.m = map[string]*Profile{
182 // NewProfile creates a new profile with the given name.
183 // If a profile with that name already exists, NewProfile panics.
186 func NewProfile(name string) *Profile {
195 p := &Profile{
203 // Lookup returns the profile with the given name, or nil if no such profile exists.
204 func Lookup(name string) *Profile {
211 func Profiles() []*Profile {
215 all := make([]*Profile, 0, len(profiles.m))
224 // Name returns this profile's name, which can be passed to Lookup to reobtain the profile.
225 func (p *Profile) Name() string {
229 // Count returns the number of execution stacks currently in the profile.
230 func (p *Profile) Count() int {
239 // Add adds the current execution stack to the profile, associated with value.
242 // call to Remove. Add panics if the profile already contains a stack for value.
257 func (p *Profile) Add(value interface{}, skip int) {
259 panic("pprof: use of uninitialized Profile")
262 panic("pprof: Add called on built-in Profile " + p.name)
271 panic("pprof: Profile.Add of duplicate value")
276 // Remove removes the execution stack associated with value from the profile.
277 // It is a no-op if the value is not in the profile.
278 func (p *Profile) Remove(value interface{}) {
284 // WriteTo writes a pprof-formatted snapshot of the profile to w.
291 // and line numbers, so that a programmer can read the profile without tools.
294 // for example, when printing the "goroutine" profile, debug=2 means to
297 func (p *Profile) WriteTo(w io.Writer, debug int) error {
299 panic("pprof: use of zero Profile")
344 // The profile will be in compressed proto format unless debug is nonzero.
372 // Print debug profile in legacy format
374 fmt.Fprintf(tw, "%s profile: total %d\n", name, p.Len())
382 // Output profile in protobuf form.
383 prof := &profile.Profile{
384 PeriodType: &profile.ValueType{Type: name, Unit: "count"},
386 Sample: make([]*profile.Sample, 0, len(keys)),
387 SampleType: []*profile.ValueType{{Type: name, Unit: "count"}},
389 locMap := make(map[uintptr]*profile.Location)
393 locs := make([]*profile.Location, len(stk))
397 loc = &profile.Location{
406 prof.Sample = append(prof.Sample, &profile.Sample{
469 // countHeap returns the number of records in the heap profile.
475 // writeHeap writes the current runtime heap profile to w.
486 // Allocate room for a slightly bigger profile,
495 // Profile grew; try again.
521 fmt.Fprintf(w, "heap profile: %d: %d [%d: %d] @ heap/%d\n",
628 // Allocate room for a slightly bigger profile,
637 // Profile grew; try again.
655 // While profiling, the profile will be buffered and written to w.
694 // This will buffer the entire profile into buf and then
695 // translate it into a profile.Profile structure. This will
696 // create two copies of all the data in the profile in memory.
698 // stream it out instead of converting the entire profile.
708 profile, err := protopprof.TranslateCPUProfile(buf.Bytes(), startTime)
710 // The runtime should never produce an invalid or truncated profile.
712 panic(fmt.Errorf("could not translate binary profile to proto format: %v", err))
715 profile.Write(w)
719 // StopCPUProfile stops the current CPU profile, if any.
721 // profile have completed.
734 // countBlock returns the number of records in the blocking profile.
740 // countMutex returns the number of records in the mutex profile.
746 // writeBlock writes the current blocking profile to w.
789 // writeMutex writes the current mutex profile to w.