metrics

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSVWriter added in v1.5.0

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

CSVWriter handles writing generation metrics to a CSV file

func NewCSVWriter added in v1.5.0

func NewCSVWriter(filename string) (*CSVWriter, error)

NewCSVWriter creates a new CSV writer for the specified file

func (*CSVWriter) Close added in v1.5.0

func (csvw *CSVWriter) Close() error

Close closes the CSV file and flushes any remaining data

func (*CSVWriter) WriteMetrics added in v1.5.0

func (csvw *CSVWriter) WriteMetrics(metrics GenerationMetrics) error

WriteMetrics writes a single generation metrics row to the CSV

type GenerationMetrics

type GenerationMetrics struct {
	Generation      int
	Duration        time.Duration
	BestFitness     float64
	AvgFitness      float64
	MinFitness      float64
	MaxFitness      float64
	BestDescription string
	MinDepth        int
	MaxDepth        int
	AvgDepth        float64
	PopulationSize  int
	Timestamp       time.Time
}

GenerationMetrics contains metrics for a single generation

type MetricsHandler added in v1.5.0

type MetricsHandler func(GenerationMetrics)

MetricsHandler represents a function that handles generation metrics

func CreateCSVHandler added in v1.5.0

func CreateCSVHandler(filename string) (MetricsHandler, error)

CreateCSVHandler creates a metrics handler function that writes to CSV

type MetricsStreamer

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

MetricsStreamer handles async streaming of generation metrics

func NewMetricsStreamer

func NewMetricsStreamer(metricsChan <-chan GenerationMetrics) *MetricsStreamer

NewMetricsStreamer creates a new metrics streamer

func (*MetricsStreamer) Start

func (ms *MetricsStreamer) Start(ctx context.Context)

Start begins streaming metrics to all subscribers

func (*MetricsStreamer) Stop

func (ms *MetricsStreamer) Stop()

Stop stops the streamer and closes all subscriber channels

func (*MetricsStreamer) Subscribe

func (ms *MetricsStreamer) Subscribe() <-chan GenerationMetrics

Subscribe returns a channel that will receive metrics

Jump to

Keyboard shortcuts

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