package debug
import "git.sr.ht/~shulhan/pakakeh.go/lib/debug"
Package debug provide library for profiling Go program. Its a wrapper for standard runtime and runtime/pprof packages.
Index ¶
Functions ¶
func WriteHeapProfile ¶
WriteHeapProfile write memory profile into "/tmp/{prefix}.pid.heap.pprof". If keepAlive is true, the file will be keep opened until error happened, or caller send keepAlive=false, or when program end.
Types ¶
type CPUProfile ¶
type CPUProfile struct {
// contains filtered or unexported fields
}
CPUProfile provide a wrapper to starting and stopping CPU profiler from package "runtime/pprof".
func NewCPUProfile ¶
func NewCPUProfile(prefix string) (prof *CPUProfile)
NewCPUProfile create and start the CPU profiler. On success, it will return the running profiler; otherwise it will return nil. Do not forget to call Stop() when finished.
func (*CPUProfile) Stop ¶
func (prof *CPUProfile) Stop()
Stop the CPU profiler.
type MemHeap ¶
type MemHeap struct { // RelHeapAlloc difference between heap allocation, relative to the // first time this object initialized. RelHeapAlloc int64 // RelHeapObjects difference between heap objects, relative to the // first time this object initialized. RelHeapObjects int64 // DiffHeapObject different between last heap objects and with current // relative heap objects. // This value is equal to MemStats.Mallocs - MemStats.Frees. // If its positive its means the number of objects allocated, // otherwise its represent the number of objects freed. DiffHeapObjects int64 // contains filtered or unexported fields }
MemHeap store the difference between heap allocation.
func NewMemHeap ¶
func NewMemHeap() (memHeap *MemHeap)
NewMemHeap create and initialize MemStatsDiff for the first time.
func (*MemHeap) Collect ¶
func (msd *MemHeap) Collect()
Collect and compute the difference on the current heap allocation (in bytes) and heap objects.
Source Files ¶
cpu_profile.go debug.go memheap.go pprof.go
- Version
- v0.60.0 (latest)
- Published
- Feb 1, 2025
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 10 minutes ago –
Tools for package owners.