profiling

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EstimateMatrixMemory

func EstimateMatrixMemory(rows, cols int) uint64

EstimateMatrixMemory estimates memory usage for a matrix

func FormatBytes

func FormatBytes(bytes uint64) string

FormatBytes formats bytes in human-readable format

func MonitorGoroutines

func MonitorGoroutines(duration time.Duration, interval time.Duration) []int

MonitorGoroutines monitors goroutine count over time

func WriteHeapProfile

func WriteHeapProfile(filename string) error

WriteHeapProfile writes a heap profile to file

Types

type LeakCheckpoint

type LeakCheckpoint struct {
	Label      string
	Timestamp  time.Time
	Goroutines int
	MemAlloc   uint64
	Leaked     bool
	Message    string
}

LeakCheckpoint represents a leak detection checkpoint

type LeakDetector

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

LeakDetector detects goroutine and memory leaks

func NewLeakDetector

func NewLeakDetector() *LeakDetector

NewLeakDetector creates a new leak detector

func (*LeakDetector) CheckGoroutines

func (ld *LeakDetector) CheckGoroutines(label string) LeakCheckpoint

CheckGoroutines checks for goroutine leaks

func (*LeakDetector) CheckMemory

func (ld *LeakDetector) CheckMemory(label string, threshold float64) LeakCheckpoint

CheckMemory checks for memory leaks after GC

func (*LeakDetector) GetReport

func (ld *LeakDetector) GetReport() LeakReport

GetReport returns a summary of all checkpoints

type LeakReport

type LeakReport struct {
	InitialGoroutines int
	InitialMemory     uint64
	Checkpoints       []LeakCheckpoint
	Leaks             []LeakCheckpoint
	HasLeaks          bool
}

LeakReport summarizes leak detection results

func DetectLeaksInFunc

func DetectLeaksInFunc(name string, fn func()) LeakReport

DetectLeaksInFunc runs a function and checks for leaks

type MemoryProfiler

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

MemoryProfiler tracks memory usage during operations

func NewMemoryProfiler

func NewMemoryProfiler() *MemoryProfiler

NewMemoryProfiler creates a new memory profiler

func (*MemoryProfiler) Checkpoint

func (mp *MemoryProfiler) Checkpoint(label string)

Checkpoint records memory state at a specific point

func (*MemoryProfiler) Start

func (mp *MemoryProfiler) Start(label string)

Start begins memory profiling

func (*MemoryProfiler) Stop

func (mp *MemoryProfiler) Stop() MemorySummary

Stop ends profiling and returns summary

type MemorySnapshot

type MemorySnapshot struct {
	Label       string
	Timestamp   time.Time
	AllocBytes  uint64
	TotalAlloc  uint64
	HeapAlloc   uint64
	HeapObjects uint64
	NumGC       uint32
}

MemorySnapshot represents memory state at a point in time

type MemorySummary

type MemorySummary struct {
	InitialAlloc   uint64
	FinalAlloc     uint64
	PeakAlloc      uint64
	TotalAllocated uint64
	NumGCs         uint32
	Measurements   []MemorySnapshot
}

MemorySummary contains profiling results

func ProfileFunc

func ProfileFunc(name string, fn func()) MemorySummary

ProfileFunc profiles memory usage of a function

Jump to

Keyboard shortcuts

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