profiling

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package profiling provides runtime profiling and performance monitoring

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CPUProfile

type CPUProfile struct {
	NumCPU       int
	NumGoroutine int
	NumCgoCall   int64
	Timestamp    time.Time
}

CPUProfile tracks CPU usage statistics

type Config

type Config struct {
	Enabled       bool
	DataDir       string
	CPUProfile    bool
	MemProfile    bool
	GoroutineDump bool
	Trace         bool
	Interval      time.Duration
}

Config for profiling manager

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default profiling configuration

type GCStats

type GCStats struct {
	NumGC      uint32
	PauseTotal time.Duration
	PauseAvg   time.Duration
	PauseMax   time.Duration
	PauseHist  []time.Duration
	Timestamp  time.Time
}

GCStats tracks garbage collection statistics

type GoroutineStats

type GoroutineStats struct {
	Count     int
	MaxCount  int
	AvgCount  int
	History   []int
	Timestamp time.Time
}

GoroutineStats tracks goroutine information

type Manager

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

Manager handles profiling operations

func NewManager

func NewManager(cfg Config, logger *slog.Logger) *Manager

NewManager creates a new profiling manager

func (*Manager) GenerateReport

func (m *Manager) GenerateReport() (*Report, error)

GenerateReport creates a performance report

func (*Manager) GetAllStats

func (m *Manager) GetAllStats() map[string]interface{}

GetAllStats returns all current statistics

func (*Manager) GetCPUProfile

func (m *Manager) GetCPUProfile() *CPUProfile

GetCPUProfile returns current CPU profile

func (*Manager) GetGCStats

func (m *Manager) GetGCStats() *GCStats

GetGCStats returns GC statistics

func (*Manager) GetGoroutineStats

func (m *Manager) GetGoroutineStats() *GoroutineStats

GetGoroutineStats returns goroutine statistics

func (*Manager) GetMemProfile

func (m *Manager) GetMemProfile() *MemProfile

GetMemProfile returns current memory profile

func (*Manager) Start

func (m *Manager) Start() error

Start begins profiling collection

func (*Manager) StartCPUProfile

func (m *Manager) StartCPUProfile(duration time.Duration) (string, error)

StartCPUProfile starts CPU profiling

func (*Manager) StartTrace

func (m *Manager) StartTrace(duration time.Duration) (string, error)

StartTrace starts execution tracing

func (*Manager) Stop

func (m *Manager) Stop() error

Stop ends profiling collection

func (*Manager) StopCPUProfile

func (m *Manager) StopCPUProfile() error

StopCPUProfile stops CPU profiling

func (*Manager) StopTrace

func (m *Manager) StopTrace() error

StopTrace stops execution tracing

func (*Manager) WriteGoroutineProfile

func (m *Manager) WriteGoroutineProfile() (string, error)

WriteGoroutineProfile writes goroutine profile to file

func (*Manager) WriteHeapProfile

func (m *Manager) WriteHeapProfile() (string, error)

WriteHeapProfile writes current heap profile to file

type MemProfile

type MemProfile struct {
	Alloc        uint64
	TotalAlloc   uint64
	Sys          uint64
	NumGC        uint32
	HeapAlloc    uint64
	HeapSys      uint64
	HeapIdle     uint64
	HeapInuse    uint64
	HeapReleased uint64
	StackInuse   uint64
	StackSys     uint64
	Timestamp    time.Time
}

MemProfile tracks memory statistics

type Report

type Report struct {
	Timestamp  time.Time
	MemStats   MemProfile
	CPUStats   CPUProfile
	Goroutines GoroutineStats
	GCStats    GCStats
}

Report contains performance data

func (*Report) WriteToFile

func (r *Report) WriteToFile(path string) error

WriteToFile saves report to JSON file

Jump to

Keyboard shortcuts

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