Documentation
¶
Index ¶
- type BatchOperationTracker
- type BenchmarkFunc
- type BenchmarkOptions
- type BenchmarkResult
- type BenchmarkSuite
- func (bs *BenchmarkSuite) CompareBenchmarks(baseline, current *BenchmarkResult) map[string]interface{}
- func (bs *BenchmarkSuite) GetResults() []BenchmarkResult
- func (bs *BenchmarkSuite) PrintResults()
- func (bs *BenchmarkSuite) RunBenchmark(ctx context.Context, name string, fn BenchmarkFunc, opts *BenchmarkOptions) (*BenchmarkResult, error)
- func (bs *BenchmarkSuite) RunSimpleBenchmark(ctx context.Context, name string, fn SimpleBenchmarkFunc, iterations int, ...) (*BenchmarkResult, error)
- type OperationMetrics
- type PerformanceMiddleware
- func (pm *PerformanceMiddleware) NewBatchOperationTracker(operationName string, batchSize int) *BatchOperationTracker
- func (pm *PerformanceMiddleware) TrackOperation(_ context.Context, operationName string, operation func() error) error
- func (pm *PerformanceMiddleware) TrackOperationWithProfiling(ctx context.Context, operationName string, profileTypes []ProfileType, ...) error
- func (pm *PerformanceMiddleware) WrapFunction(operationName string, fn func() error) func() error
- func (pm *PerformanceMiddleware) WrapFunctionWithContext(operationName string, fn func(context.Context) error) func(context.Context) error
- type ProfileConfig
- type ProfileSession
- type ProfileType
- type Profiler
- func (p *Profiler) GetRuntimeStats() map[string]interface{}
- func (p *Profiler) ListActiveSessions() map[string]ProfileSession
- func (p *Profiler) ProfileOperation(_ context.Context, operationName string, profileTypes []ProfileType, ...) error
- func (p *Profiler) Start(ctx context.Context) error
- func (p *Profiler) StartProfile(profileType ProfileType) (string, error)
- func (p *Profiler) Stop() error
- func (p *Profiler) StopProfile(sessionID string) error
- type SimpleBenchmarkFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchOperationTracker ¶
type BatchOperationTracker struct {
// contains filtered or unexported fields
}
BatchOperationTracker tracks performance metrics for batch operations.
func (*BatchOperationTracker) Finish ¶
func (bot *BatchOperationTracker) Finish()
Finish completes the batch operation tracking.
func (*BatchOperationTracker) TrackItem ¶
func (bot *BatchOperationTracker) TrackItem(success bool)
TrackItem tracks completion of a single item in the batch.
type BenchmarkFunc ¶
BenchmarkFunc represents a function to be benchmarked.
type BenchmarkOptions ¶
type BenchmarkOptions struct {
Iterations int `json:"iterations"`
Duration time.Duration `json:"duration"`
WarmupRuns int `json:"warmup_runs"`
Concurrency int `json:"concurrency"`
MemoryProfiling bool `json:"memory_profiling"`
CPUProfiling bool `json:"cpu_profiling"`
}
BenchmarkOptions configures benchmark execution.
func DefaultBenchmarkOptions ¶
func DefaultBenchmarkOptions() *BenchmarkOptions
DefaultBenchmarkOptions returns default benchmark options.
type BenchmarkResult ¶
type BenchmarkResult struct {
Name string `json:"name"`
Operations int `json:"operations"`
Duration time.Duration `json:"duration"`
NsPerOp int64 `json:"ns_per_op"`
OpsPerSec float64 `json:"ops_per_sec"`
AllocBytesPerOp int64 `json:"alloc_bytes_per_op"`
AllocsPerOp int64 `json:"allocs_per_op"`
MemoryBefore uint64 `json:"memory_before"`
MemoryAfter uint64 `json:"memory_after"`
GoroutinesBefore int `json:"goroutines_before"`
GoroutinesAfter int `json:"goroutines_after"`
Percentiles map[string]time.Duration `json:"percentiles"`
Timestamp time.Time `json:"timestamp"`
}
BenchmarkResult holds the results of a benchmark run.
type BenchmarkSuite ¶
type BenchmarkSuite struct {
// contains filtered or unexported fields
}
BenchmarkSuite manages and runs performance benchmarks.
func NewBenchmarkSuite ¶
func NewBenchmarkSuite(profiler *Profiler) *BenchmarkSuite
NewBenchmarkSuite creates a new benchmark suite.
func (*BenchmarkSuite) CompareBenchmarks ¶
func (bs *BenchmarkSuite) CompareBenchmarks(baseline, current *BenchmarkResult) map[string]interface{}
CompareBenchmarks compares two benchmark results.
func (*BenchmarkSuite) GetResults ¶
func (bs *BenchmarkSuite) GetResults() []BenchmarkResult
GetResults returns all benchmark results.
func (*BenchmarkSuite) PrintResults ¶
func (bs *BenchmarkSuite) PrintResults()
PrintResults prints benchmark results in a formatted way.
func (*BenchmarkSuite) RunBenchmark ¶
func (bs *BenchmarkSuite) RunBenchmark(ctx context.Context, name string, fn BenchmarkFunc, opts *BenchmarkOptions) (*BenchmarkResult, error)
RunBenchmark executes a benchmark with the given options.
func (*BenchmarkSuite) RunSimpleBenchmark ¶
func (bs *BenchmarkSuite) RunSimpleBenchmark(ctx context.Context, name string, fn SimpleBenchmarkFunc, iterations int, duration time.Duration) (*BenchmarkResult, error)
RunSimpleBenchmark executes a simple benchmark with specified parameters.
type OperationMetrics ¶
type OperationMetrics struct {
Name string
StartTime time.Time
EndTime time.Time
Duration time.Duration
GoroutinesBefore int
GoroutinesAfter int
MemoryBefore uint64
MemoryAfter uint64
Success bool
Error error
}
OperationMetrics holds performance metrics for an operation.
type PerformanceMiddleware ¶
type PerformanceMiddleware struct {
// contains filtered or unexported fields
}
PerformanceMiddleware provides performance monitoring capabilities.
func NewPerformanceMiddleware ¶
func NewPerformanceMiddleware(profiler *Profiler, enabled bool) *PerformanceMiddleware
NewPerformanceMiddleware creates a new performance middleware.
func (*PerformanceMiddleware) NewBatchOperationTracker ¶
func (pm *PerformanceMiddleware) NewBatchOperationTracker(operationName string, batchSize int) *BatchOperationTracker
NewBatchOperationTracker creates a new batch operation tracker.
func (*PerformanceMiddleware) TrackOperation ¶
func (pm *PerformanceMiddleware) TrackOperation(_ context.Context, operationName string, operation func() error) error
TrackOperation wraps an operation with performance tracking.
func (*PerformanceMiddleware) TrackOperationWithProfiling ¶
func (pm *PerformanceMiddleware) TrackOperationWithProfiling(ctx context.Context, operationName string, profileTypes []ProfileType, operation func() error) error
TrackOperationWithProfiling wraps an operation with performance tracking and profiling.
func (*PerformanceMiddleware) WrapFunction ¶
func (pm *PerformanceMiddleware) WrapFunction(operationName string, fn func() error) func() error
WrapFunction creates a performance-tracked version of a function.
func (*PerformanceMiddleware) WrapFunctionWithContext ¶
func (pm *PerformanceMiddleware) WrapFunctionWithContext(operationName string, fn func(context.Context) error) func(context.Context) error
WrapFunctionWithContext creates a performance-tracked version of a function with context.
type ProfileConfig ¶
type ProfileConfig struct {
Enabled bool `yaml:"enabled" json:"enabled"`
HTTPPort int `yaml:"http_port" json:"http_port"`
OutputDir string `yaml:"output_dir" json:"output_dir"`
AutoProfile bool `yaml:"auto_profile" json:"auto_profile"`
CPUDuration time.Duration `yaml:"cpu_duration" json:"cpu_duration"`
SampleRate int `yaml:"sample_rate" json:"sample_rate"`
BlockRate int `yaml:"block_rate" json:"block_rate"`
MutexFraction int `yaml:"mutex_fraction" json:"mutex_fraction"`
}
ProfileConfig holds configuration for profiling.
func DefaultProfileConfig ¶
func DefaultProfileConfig() *ProfileConfig
DefaultProfileConfig returns default profiling configuration.
type ProfileSession ¶
ProfileSession represents an active profiling session.
type ProfileType ¶
type ProfileType string
ProfileType represents different types of profiling.
const ( ProfileTypeCPU ProfileType = "cpu" ProfileTypeMemory ProfileType = "memory" ProfileTypeGoroutine ProfileType = "goroutine" ProfileTypeBlock ProfileType = "block" ProfileTypeMutex ProfileType = "mutex" ProfileTypeThreadCreate ProfileType = "threadcreate" )
type Profiler ¶
type Profiler struct {
// contains filtered or unexported fields
}
Profiler provides performance profiling capabilities.
func NewProfiler ¶
func NewProfiler(config *ProfileConfig) *Profiler
NewProfiler creates a new profiler instance.
func (*Profiler) GetRuntimeStats ¶
GetRuntimeStats returns current runtime statistics.
func (*Profiler) ListActiveSessions ¶
func (p *Profiler) ListActiveSessions() map[string]ProfileSession
ListActiveSessions returns information about currently active profiling sessions.
func (*Profiler) ProfileOperation ¶
func (p *Profiler) ProfileOperation(_ context.Context, operationName string, profileTypes []ProfileType, operation func() error) error
ProfileOperation runs an operation with automatic profiling.
func (*Profiler) StartProfile ¶
func (p *Profiler) StartProfile(profileType ProfileType) (string, error)
StartProfile begins a profiling session for the specified type.
func (*Profiler) StopProfile ¶
StopProfile ends a profiling session and saves the results.
type SimpleBenchmarkFunc ¶
SimpleBenchmarkFunc represents a simple function to be benchmarked (for compatibility).