profiling

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryProfiler

type MemoryProfiler struct {
	// contains filtered or unexported fields
}

MemoryProfiler provides tools for memory profiling and optimization

func NewMemoryProfiler

func NewMemoryProfiler(options *ProfilerOptions) (*MemoryProfiler, error)

NewMemoryProfiler creates a new memory profiler

func (*MemoryProfiler) CaptureHeapProfile

func (p *MemoryProfiler) CaptureHeapProfile(label string) (string, error)

CaptureHeapProfile captures a heap profile

func (*MemoryProfiler) CheckMemoryThresholds

func (p *MemoryProfiler) CheckMemoryThresholds()

CheckMemoryThresholds checks memory thresholds and generates alerts

func (*MemoryProfiler) ClearAlerts

func (p *MemoryProfiler) ClearAlerts()

ClearAlerts clears memory usage alerts

func (*MemoryProfiler) CompareSnapshots

func (p *MemoryProfiler) CompareSnapshots(name1, name2 string) (map[string]interface{}, error)

CompareSnapshots compares two memory snapshots

func (*MemoryProfiler) CreateSnapshot

func (p *MemoryProfiler) CreateSnapshot(name string)

CreateSnapshot creates a memory snapshot

func (*MemoryProfiler) ForceGC

func (p *MemoryProfiler) ForceGC()

ForceGC forces garbage collection

func (*MemoryProfiler) GetAlerts

func (p *MemoryProfiler) GetAlerts() []string

GetAlerts returns memory usage alerts

func (*MemoryProfiler) GetFormattedMemoryStats

func (p *MemoryProfiler) GetFormattedMemoryStats() map[string]interface{}

GetFormattedMemoryStats returns formatted memory statistics

func (*MemoryProfiler) GetGCPauseTime

func (p *MemoryProfiler) GetGCPauseTime() float64

GetGCPauseTime returns the last GC pause time in ms

func (*MemoryProfiler) GetGCStats

func (p *MemoryProfiler) GetGCStats() map[string]interface{}

GetGCStats returns GC statistics

func (*MemoryProfiler) GetInterval

func (p *MemoryProfiler) GetInterval() time.Duration

GetInterval returns the profiling interval

func (*MemoryProfiler) GetLastCaptureTime

func (p *MemoryProfiler) GetLastCaptureTime() time.Time

GetLastCaptureTime returns the time of the last profile capture

func (*MemoryProfiler) GetMemoryStats

func (p *MemoryProfiler) GetMemoryStats() runtime.MemStats

GetMemoryStats returns memory statistics

func (*MemoryProfiler) GetMemoryUsage

func (p *MemoryProfiler) GetMemoryUsage() float64

GetMemoryUsage returns the current memory usage in MB

func (*MemoryProfiler) GetOutputDir

func (p *MemoryProfiler) GetOutputDir() string

GetOutputDir returns the output directory

func (*MemoryProfiler) GetProfileCount

func (p *MemoryProfiler) GetProfileCount() int

GetProfileCount returns the number of profiles captured

func (*MemoryProfiler) IsRunning

func (p *MemoryProfiler) IsRunning() bool

IsRunning returns if automatic profiling is running

func (*MemoryProfiler) SetGCThreshold

func (p *MemoryProfiler) SetGCThreshold(threshold int64)

SetGCThreshold sets the GC pause time threshold

func (*MemoryProfiler) SetInterval

func (p *MemoryProfiler) SetInterval(interval time.Duration)

SetInterval sets the profiling interval

func (*MemoryProfiler) SetMemoryThreshold

func (p *MemoryProfiler) SetMemoryThreshold(threshold int64)

SetMemoryThreshold sets the memory usage threshold

func (*MemoryProfiler) StartAutomaticProfiling

func (p *MemoryProfiler) StartAutomaticProfiling() error

StartAutomaticProfiling starts automatic profiling

func (*MemoryProfiler) StopAutomaticProfiling

func (p *MemoryProfiler) StopAutomaticProfiling()

StopAutomaticProfiling stops automatic profiling

func (*MemoryProfiler) UpdateMemoryStats

func (p *MemoryProfiler) UpdateMemoryStats()

UpdateMemoryStats updates memory statistics

type ProfilerOptions

type ProfilerOptions struct {
	// OutputDir is the directory where profile files are saved
	OutputDir string
	// Interval is the time between automatic profile captures
	Interval time.Duration
	// MemoryThreshold is the threshold for memory usage alerts (in MB)
	MemoryThreshold int64
	// GCThreshold is the threshold for GC pause time alerts (in ms)
	GCThreshold int64
}

ProfilerOptions represents options for the memory profiler

func DefaultProfilerOptions

func DefaultProfilerOptions() *ProfilerOptions

DefaultProfilerOptions returns default profiler options

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL