performance

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BenchmarkResult

type BenchmarkResult struct {
	Name        string
	Iterations  int
	TotalTime   time.Duration
	TimePerOp   time.Duration
	AllocsPerOp int64
	BytesPerOp  int64
}

BenchmarkResult contains benchmark results

func BenchmarkOperation

func BenchmarkOperation(name string, iterations int, operation func()) BenchmarkResult

BenchmarkOperation runs a benchmark on an operation

func (BenchmarkResult) String

func (r BenchmarkResult) String() string

String returns a string representation of benchmark result

type MemoryDelta

type MemoryDelta struct {
	HeapAllocDelta   int64
	HeapObjectsDelta int64
	GoroutinesDelta  int
	GCCycles         uint32
}

MemoryDelta represents memory changes

type Metric

type Metric struct {
	Type      MetricType
	Name      string
	Value     float64
	Unit      string
	Timestamp time.Time
}

Metric represents a performance metric

type MetricType

type MetricType string

MetricType represents different types of metrics

const (
	MetricCPU       MetricType = "cpu"
	MetricMemory    MetricType = "memory"
	MetricGoroutine MetricType = "goroutine"
	MetricLatency   MetricType = "latency"
)

type ObjectPool

type ObjectPool[T any] struct {
	// contains filtered or unexported fields
}

ObjectPool provides a generic object pool for reducing allocations

func NewObjectPool

func NewObjectPool[T any](new func() T) *ObjectPool[T]

NewObjectPool creates a new object pool

func (*ObjectPool[T]) Get

func (p *ObjectPool[T]) Get() T

Get retrieves an object from the pool

func (*ObjectPool[T]) Put

func (p *ObjectPool[T]) Put(obj T)

Put returns an object to the pool

type OperationStats

type OperationStats struct {
	Name      string
	Count     int64
	TotalTime time.Duration
	MinTime   time.Duration
	MaxTime   time.Duration
	LastTime  time.Duration
	// contains filtered or unexported fields
}

OperationStats tracks statistics for a specific operation

type OperationSummary

type OperationSummary struct {
	Name        string
	Count       int64
	TotalTime   time.Duration
	AverageTime time.Duration
	MinTime     time.Duration
	MaxTime     time.Duration
	LastTime    time.Duration
}

OperationSummary provides a summary of operation statistics

type OptimizationLevel

type OptimizationLevel int

OptimizationLevel represents the level of optimization

const (
	OptimizationNone OptimizationLevel = iota
	OptimizationLight
	OptimizationModerate
	OptimizationAggressive
)

type Optimizer

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

Optimizer provides performance optimization recommendations and automatic tuning

func NewOptimizer

func NewOptimizer(profiler *Profiler) *Optimizer

NewOptimizer creates a new performance optimizer

func (*Optimizer) Analyze

func (o *Optimizer) Analyze() []Recommendation

Analyze performs performance analysis and generates recommendations

func (*Optimizer) EnableAutoTune

func (o *Optimizer) EnableAutoTune(enable bool)

EnableAutoTune enables automatic performance tuning

func (*Optimizer) GetOptimizationSummary

func (o *Optimizer) GetOptimizationSummary() string

GetOptimizationSummary returns a summary of optimizations

func (*Optimizer) SetLevel

func (o *Optimizer) SetLevel(level OptimizationLevel)

SetLevel sets the optimization level

func (*Optimizer) TuneForBatchOperations

func (o *Optimizer) TuneForBatchOperations()

TuneForBatchOperations optimizes settings for batch operations

func (*Optimizer) TuneForInteractive

func (o *Optimizer) TuneForInteractive()

TuneForInteractive optimizes settings for interactive use

type Profiler

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

Profiler handles performance profiling

func NewProfiler

func NewProfiler() *Profiler

NewProfiler creates a new profiler

func (*Profiler) CaptureMemoryStats

func (p *Profiler) CaptureMemoryStats() runtime.MemStats

CaptureMemoryStats captures current memory statistics

func (*Profiler) FindMemoryLeaks

func (p *Profiler) FindMemoryLeaks() []string

FindMemoryLeaks looks for potential memory leaks

func (*Profiler) GetMemoryDelta

func (p *Profiler) GetMemoryDelta() MemoryDelta

GetMemoryDelta returns memory changes since baseline

func (*Profiler) GetOperationStats

func (p *Profiler) GetOperationStats() map[string]OperationSummary

GetOperationStats returns statistics for all operations

func (*Profiler) Report

func (p *Profiler) Report() string

Report generates a performance report

func (*Profiler) StartOperation

func (p *Profiler) StartOperation(name string) func()

StartOperation starts timing an operation

type Recommendation

type Recommendation struct {
	Category    string
	Issue       string
	Impact      string // "High", "Medium", "Low"
	Suggestion  string
	AutoFixable bool
}

Recommendation represents a performance optimization recommendation

Jump to

Keyboard shortcuts

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