Documentation
¶
Overview ¶
Package profiling provides tools for profiling and performance measurement.
Package profiling provides tools for profiling and performance measurement.
Package profiling provides tools for profiling and performance measurement.
Index ¶
- type CIReporter
- type CIReporterConfig
- type MetricSeries
- type MetricSummary
- type MetricType
- type MetricUnit
- type MetricValue
- type Profiler
- func (p *Profiler) CaptureCPUProfile(filePath string, duration time.Duration) error
- func (p *Profiler) CaptureMemoryProfile(filePath string) error
- func (p *Profiler) GetMetric(name string) (*MetricSeries, bool)
- func (p *Profiler) GetMetrics() map[string]*MetricSeries
- func (p *Profiler) GetReport() map[string]interface{}
- func (p *Profiler) RecordDuration(name string, duration time.Duration, labels map[string]string)
- func (p *Profiler) RecordGoroutineCount(name string, labels map[string]string)
- func (p *Profiler) RecordMemoryUsage(name string, labels map[string]string)
- func (p *Profiler) RecordMetric(name string, value float64, labels map[string]string)
- func (p *Profiler) RegisterMetric(name string, metricType MetricType, description string, unit MetricUnit)
- func (p *Profiler) SaveReport(filePath string) error
- func (p *Profiler) Start() error
- func (p *Profiler) StartTimer(name string, labels map[string]string) func()
- func (p *Profiler) Stop() error
- type ProfilerConfig
- type TemplateOperation
- type TemplateProfiler
- func (p *TemplateProfiler) CompareWithBaseline() map[string]map[string]interface{}
- func (p *TemplateProfiler) EstablishBaseline(ctx context.Context, sources []types.TemplateSource, iterations int) error
- func (p *TemplateProfiler) ProfileTemplateExecution(ctx context.Context, template *format.Template, options map[string]interface{}) (*interfaces.TemplateResult, error)
- func (p *TemplateProfiler) ProfileTemplateExecutionBatch(ctx context.Context, templates []*format.Template, ...) ([]*interfaces.TemplateResult, error)
- func (p *TemplateProfiler) ProfileTemplateLoad(ctx context.Context, source string, sourceType string) (*format.Template, error)
- func (p *TemplateProfiler) ProfileTemplateLoadBatch(ctx context.Context, source string, sourceType string) ([]*format.Template, error)
- func (p *TemplateProfiler) SaveComparisonReport(filePath string) error
- func (p *TemplateProfiler) Start() error
- func (p *TemplateProfiler) Stop() error
- type TemplateProfilerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CIReporter ¶
type CIReporter struct {
// contains filtered or unexported fields
}
CIReporter generates performance reports for CI/CD pipelines
func NewCIReporter ¶
func NewCIReporter(profiler *Profiler, templateProfiler *TemplateProfiler, config *CIReporterConfig) *CIReporter
NewCIReporter creates a new CI reporter
func (*CIReporter) CheckThresholds ¶
func (r *CIReporter) CheckThresholds() (bool, map[string]interface{})
CheckThresholds checks if any performance thresholds are exceeded
func (*CIReporter) GenerateReports ¶
func (r *CIReporter) GenerateReports() error
GenerateReports generates performance reports
func (*CIReporter) LoadBaseline ¶
func (r *CIReporter) LoadBaseline() error
LoadBaseline loads baseline metrics from a file
func (*CIReporter) LoadThresholds ¶
func (r *CIReporter) LoadThresholds() error
LoadThresholds loads performance thresholds from a file
func (*CIReporter) SaveBaseline ¶
func (r *CIReporter) SaveBaseline() error
SaveBaseline saves baseline metrics to a file
func (*CIReporter) SaveThresholds ¶
func (r *CIReporter) SaveThresholds() error
SaveThresholds saves performance thresholds to a file
type CIReporterConfig ¶
type CIReporterConfig struct {
// ReportDir is the directory for reports
ReportDir string
// BaselineFile is the path to the baseline file
BaselineFile string
// ThresholdFile is the path to the threshold file
ThresholdFile string
// ReportFormats is a list of report formats to generate
ReportFormats []string
// FailOnThresholdExceeded determines if the CI should fail when thresholds are exceeded
FailOnThresholdExceeded bool
// PerformanceThresholds defines thresholds for metrics
PerformanceThresholds map[string]float64
}
CIReporterConfig contains configuration for the CI reporter
type MetricSeries ¶
type MetricSeries struct {
// Type is the type of metric
Type MetricType
// Description is a human-readable description of the metric
Description string
// Unit is the unit of measurement
Unit MetricUnit
// Values are the measured values
Values []MetricValue
// Summary contains summary statistics
Summary MetricSummary
// contains filtered or unexported fields
}
MetricSeries represents a series of metric measurements
type MetricSummary ¶
type MetricSummary struct {
// Min is the minimum value
Min float64
// Max is the maximum value
Max float64
// Mean is the mean value
Mean float64
// Median is the median value
Median float64
// P95 is the 95th percentile value
P95 float64
// P99 is the 99th percentile value
P99 float64
// StdDev is the standard deviation
StdDev float64
// Count is the number of measurements
Count int
}
MetricSummary contains summary statistics for a metric series
type MetricType ¶
type MetricType string
MetricType defines the type of metric being measured
const ( // TemplateLoadTime measures time to load templates TemplateLoadTime MetricType = "template_load_time" // TemplateRenderTime measures time to render templates TemplateRenderTime MetricType = "template_render_time" // MemoryUsage measures memory consumption MemoryUsage MetricType = "memory_usage" // CPUUsage measures CPU utilization CPUUsage MetricType = "cpu_usage" // ResponseTime measures time to generate a response ResponseTime MetricType = "response_time" // ThroughputMetric measures operations per second ThroughputMetric MetricType = "throughput" // LatencyMetric measures operation latency LatencyMetric MetricType = "latency" // ErrorRateMetric measures error rate ErrorRateMetric MetricType = "error_rate" // CacheHitRateMetric measures cache hit rate CacheHitRateMetric MetricType = "cache_hit_rate" // DatabaseQueryCount measures number of database queries DatabaseQueryCount MetricType = "db_query_count" // NetworkIOMetric measures network I/O NetworkIOMetric MetricType = "network_io" // DiskIOMetric measures disk I/O DiskIOMetric MetricType = "disk_io" // GoroutineCount measures number of goroutines GoroutineCount MetricType = "goroutine_count" )
type MetricUnit ¶
type MetricUnit string
MetricUnit defines the unit of measurement for a metric
const ( // Milliseconds for time measurements Milliseconds MetricUnit = "ms" // Bytes for memory measurements Bytes MetricUnit = "bytes" // Megabytes for memory measurements Megabytes MetricUnit = "MB" // Percentage for utilization measurements Percentage MetricUnit = "percent" // Count for counting measurements Count MetricUnit = "count" // OpsPerSecond for throughput measurements OpsPerSecond MetricUnit = "ops/sec" // BytesPerSecond for I/O measurements BytesPerSecond MetricUnit = "bytes/sec" )
type MetricValue ¶
type MetricValue struct {
// Value is the measured value
Value float64
// Unit is the unit of measurement
Unit MetricUnit
// Timestamp is when the measurement was taken
Timestamp time.Time
// Labels are additional metadata for the measurement
Labels map[string]string
}
MetricValue represents a single metric measurement
type Profiler ¶
type Profiler struct {
// contains filtered or unexported fields
}
Profiler collects and analyzes performance metrics
func NewProfiler ¶
func NewProfiler(config *ProfilerConfig) *Profiler
NewProfiler creates a new profiler
func (*Profiler) CaptureCPUProfile ¶
CaptureCPUProfile captures a CPU profile
func (*Profiler) CaptureMemoryProfile ¶
CaptureMemoryProfile captures a memory profile
func (*Profiler) GetMetric ¶
func (p *Profiler) GetMetric(name string) (*MetricSeries, bool)
GetMetric gets a metric by name
func (*Profiler) GetMetrics ¶
func (p *Profiler) GetMetrics() map[string]*MetricSeries
GetMetrics gets all metrics
func (*Profiler) RecordDuration ¶
RecordDuration records a duration metric
func (*Profiler) RecordGoroutineCount ¶
RecordGoroutineCount records current goroutine count
func (*Profiler) RecordMemoryUsage ¶
RecordMemoryUsage records current memory usage
func (*Profiler) RecordMetric ¶
RecordMetric records a metric value
func (*Profiler) RegisterMetric ¶
func (p *Profiler) RegisterMetric(name string, metricType MetricType, description string, unit MetricUnit)
RegisterMetric registers a new metric
func (*Profiler) SaveReport ¶
SaveReport saves a profiling report to a file
func (*Profiler) StartTimer ¶
StartTimer starts a timer for measuring durations
type ProfilerConfig ¶
type ProfilerConfig struct {
// EnableCPUProfiling enables CPU profiling
EnableCPUProfiling bool
// EnableMemProfiling enables memory profiling
EnableMemProfiling bool
// CPUProfilePath is the path to save CPU profiles
CPUProfilePath string
// MemProfilePath is the path to save memory profiles
MemProfilePath string
// SamplingInterval is how often to sample metrics
SamplingInterval time.Duration
// MaxSamples is the maximum number of samples to keep
MaxSamples int
// Tags are additional metadata for all metrics
Tags map[string]string
}
ProfilerConfig contains configuration for the profiler
type TemplateOperation ¶
type TemplateOperation string
TemplateOperation defines the type of template operation being profiled
const ( // LoadOperation represents template loading LoadOperation TemplateOperation = "load" // ParseOperation represents template parsing ParseOperation TemplateOperation = "parse" // RenderOperation represents template rendering RenderOperation TemplateOperation = "render" // ExecuteOperation represents template execution ExecuteOperation TemplateOperation = "execute" // ValidationOperation represents template validation ValidationOperation TemplateOperation = "validate" )
type TemplateProfiler ¶
type TemplateProfiler struct {
// contains filtered or unexported fields
}
TemplateProfiler profiles template operations
func NewTemplateProfiler ¶
func NewTemplateProfiler(templateManager types.TemplateManager, config *TemplateProfilerConfig) *TemplateProfiler
NewTemplateProfiler creates a new template profiler
func (*TemplateProfiler) CompareWithBaseline ¶
func (p *TemplateProfiler) CompareWithBaseline() map[string]map[string]interface{}
CompareWithBaseline compares current metrics with baseline
func (*TemplateProfiler) EstablishBaseline ¶
func (p *TemplateProfiler) EstablishBaseline(ctx context.Context, sources []types.TemplateSource, iterations int) error
EstablishBaseline establishes baseline metrics
func (*TemplateProfiler) ProfileTemplateExecution ¶
func (p *TemplateProfiler) ProfileTemplateExecution(ctx context.Context, template *format.Template, options map[string]interface{}) (*interfaces.TemplateResult, error)
ProfileTemplateExecution profiles template execution
func (*TemplateProfiler) ProfileTemplateExecutionBatch ¶
func (p *TemplateProfiler) ProfileTemplateExecutionBatch(ctx context.Context, templates []*format.Template, options map[string]interface{}) ([]*interfaces.TemplateResult, error)
ProfileTemplateExecutionBatch profiles batch template execution
func (*TemplateProfiler) ProfileTemplateLoad ¶
func (p *TemplateProfiler) ProfileTemplateLoad(ctx context.Context, source string, sourceType string) (*format.Template, error)
ProfileTemplateLoad profiles template loading
func (*TemplateProfiler) ProfileTemplateLoadBatch ¶
func (p *TemplateProfiler) ProfileTemplateLoadBatch(ctx context.Context, source string, sourceType string) ([]*format.Template, error)
ProfileTemplateLoadBatch profiles batch template loading
func (*TemplateProfiler) SaveComparisonReport ¶
func (p *TemplateProfiler) SaveComparisonReport(filePath string) error
SaveComparisonReport saves a comparison report to a file
type TemplateProfilerConfig ¶
type TemplateProfilerConfig struct {
// ProfilerConfig is the configuration for the underlying profiler
ProfilerConfig *ProfilerConfig
// EnableDetailedProfiling enables detailed profiling
EnableDetailedProfiling bool
// EnableContinuousMonitoring enables continuous monitoring
EnableContinuousMonitoring bool
// MonitoringInterval is how often to collect metrics
MonitoringInterval time.Duration
// BaselineFilePath is the path to save baseline metrics
BaselineFilePath string
// ReportFilePath is the path to save profiling reports
ReportFilePath string
}
TemplateProfilerConfig contains configuration for the template profiler