stats

package
v0.0.0-...-5d3badf Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockCollector

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

BlockCollector subscribes to new blocks and tracks block metrics

func NewBlockCollector

func NewBlockCollector(seiChainID string) *BlockCollector

NewBlockCollector creates a new block data collector

func (*BlockCollector) GetBlockStats

func (bc *BlockCollector) GetBlockStats() BlockStats

GetBlockStats returns current block statistics

func (*BlockCollector) GetWindowBlockStats

func (bc *BlockCollector) GetWindowBlockStats() BlockStats

GetWindowBlockStats returns current window-based block statistics

func (*BlockCollector) GetWindowBlockTimePercentile

func (bc *BlockCollector) GetWindowBlockTimePercentile(percentile int) time.Duration

func (*BlockCollector) ResetWindowStats

func (bc *BlockCollector) ResetWindowStats()

ResetWindowStats resets the window-based statistics for the next reporting period

func (*BlockCollector) Run

func (bc *BlockCollector) Run(ctx context.Context, firstEndpoint string) error

Start begins block subscription and data collection

type BlockStats

type BlockStats struct {
	MaxBlockNumber uint64        `json:"max_block_number"`
	P50BlockTime   time.Duration `json:"p50_block_time"`
	P99BlockTime   time.Duration `json:"p99_block_time"`
	MaxBlockTime   time.Duration `json:"max_block_time"`
	P50GasUsed     uint64        `json:"p50_gas_used"`
	P99GasUsed     uint64        `json:"p99_gas_used"`
	MaxGasUsed     uint64        `json:"max_gas_used"`
	SampleCount    int           `json:"sample_count"`
}

BlockStats represents block-related statistics

func (BlockStats) FormatBlockStats

func (bs BlockStats) FormatBlockStats() string

FormatBlockStats returns a formatted string representation of block statistics

type BlockStatsProvider

type BlockStatsProvider interface {
	GetBlockStats() BlockStats
	GetWindowBlockStats() BlockStats
	GetWindowBlockTimePercentile(percentile int) time.Duration
	ResetWindowStats()
}

type Collector

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

Collector tracks comprehensive statistics for load testing

func NewCollector

func NewCollector() *Collector

NewCollector creates a new statistics collector

func (*Collector) EmitRunSummary

func (c *Collector) EmitRunSummary(ctx context.Context)

EmitRunSummary records the run-summary gauges. Call once at shutdown.

func (*Collector) GetBlockCollector

func (c *Collector) GetBlockCollector() *BlockCollector

GetBlockCollector returns the block collector

func (*Collector) GetCumulativeBlockStats

func (c *Collector) GetCumulativeBlockStats() *BlockStats

GetCumulativeBlockStats returns cumulative block stats for final summary

func (*Collector) GetStats

func (c *Collector) GetStats() Stats

GetStats returns comprehensive statistics

func (*Collector) RecordTransaction

func (c *Collector) RecordTransaction(scenario, endpoint string, latency time.Duration, success bool)

RecordTransaction records a transaction attempt

func (*Collector) ResetWindowStats

func (c *Collector) ResetWindowStats()

ResetWindowStats resets the window statistics for all endpoints

func (*Collector) SetBlockCollector

func (c *Collector) SetBlockCollector(bc *BlockCollector)

SetBlockCollector sets the block collector for this stats collector

type EndpointPerformance

type EndpointPerformance struct {
	LatencyP50           time.Duration `json:"latency_p50"`
	LatencyP99           time.Duration `json:"latency_p99"`
	SampleCount          int           `json:"sample_count"`
	CurrentTPS           float64       `json:"current_tps"`
	MaxTPS               float64       `json:"max_tps"`
	WindowTxCount        uint64        `json:"window_tx_count"`
	WindowLatencySum     time.Duration `json:"window_latency_sum"`
	WindowLatencyCount   int           `json:"window_latency_count"`
	WindowMaxLatency     time.Duration `json:"window_max_latency"`
	WindowMinLatency     time.Duration `json:"window_min_latency"`
	CumulativeMaxTPS     float64       `json:"cumulative_max_tps"`
	CumulativeMaxLatency time.Duration `json:"cumulative_max_latency"`
}

EndpointPerformance represents detailed performance metrics for an endpoint

type EndpointStats

type EndpointStats struct {
	Endpoint    string
	P50Latency  time.Duration
	P99Latency  time.Duration
	MaxTPS      float64
	CurrentTPS  float64
	SampleCount int
	QueueDepth  int // Current queue depth for monitoring backpressure

	// Window stats
	WindowTxCount        uint64
	WindowLatencySum     time.Duration
	WindowLatencyCount   int
	WindowMaxLatency     time.Duration
	WindowMinLatency     time.Duration
	CumulativeMaxTPS     float64
	CumulativeMaxLatency time.Duration
}

EndpointStats represents statistics for a specific endpoint

type FinalStats

type FinalStats struct {
	LoadTestStatistics   LoadTestStatistics             `json:"load_test_statistics"`
	ScenarioDistribution map[string]uint64              `json:"scenario_distribution"`
	EndpointPerformance  map[string]EndpointPerformance `json:"endpoint_performance"`
	OverallTPS           OverallTPS                     `json:"overall_tps"`
	BlockStatistics      *BlockStats                    `json:"block_statistics,omitempty"`
	OverallPerformance   OverallPerformance             `json:"overall_performance"`
	GasStatistics        *BlockStats                    `json:"gas_statistics,omitempty"`
}

FinalStats represents the complete final statistics that can be marshaled to JSON

func (*FinalStats) String

func (fs *FinalStats) String() string

String returns a formatted string representation of the final statistics

type LoadTestStatistics

type LoadTestStatistics struct {
	Runtime   time.Duration `json:"runtime"`
	TotalTxs  uint64        `json:"total_txs"`
	AvgTPS    float64       `json:"avg_tps"`
	StartTime time.Time     `json:"start_time"`
}

LoadTestStatistics represents basic load test metrics

type Logger

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

Logger handles periodic statistics logging and dry-run transaction printing

func NewLogger

func NewLogger(collector *Collector, interval time.Duration, reportPath string, debug bool) *Logger

NewLogger creates a new statistics logger

func (*Logger) BuildFinalStats

func (l *Logger) BuildFinalStats() *FinalStats

BuildFinalStats creates a FinalStats struct from the current collector data

func (*Logger) LogFinalStats

func (l *Logger) LogFinalStats()

LogFinalStats logs comprehensive final statistics

func (*Logger) Run

func (l *Logger) Run(ctx context.Context) error

Start begins periodic statistics logging

type MockBlockStats

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

MockBlockStats is a test implementation of BlockStatsProvider

func NewMockBlockStats

func NewMockBlockStats() *MockBlockStats

NewMockBlockStats creates a new MockBlockStats instance

func (*MockBlockStats) GetBlockStats

func (m *MockBlockStats) GetBlockStats() BlockStats

GetBlockStats returns the preset block stats

func (*MockBlockStats) GetResetCallCount

func (m *MockBlockStats) GetResetCallCount() int

GetResetCallCount returns how many times ResetWindowStats was called

func (*MockBlockStats) GetWindowBlockStats

func (m *MockBlockStats) GetWindowBlockStats() BlockStats

GetWindowBlockStats returns the preset window block stats

func (*MockBlockStats) GetWindowBlockTimePercentile

func (m *MockBlockStats) GetWindowBlockTimePercentile(percentile int) time.Duration

GetWindowBlockTimePercentile returns the preset value for the given percentile

func (*MockBlockStats) HasPendingPercentile

func (m *MockBlockStats) HasPendingPercentile(percentile int) bool

HasPendingPercentile checks if there's a pending value for the given percentile

func (*MockBlockStats) ResetWindowStats

func (m *MockBlockStats) ResetWindowStats()

ResetWindowStats tracks the number of times it's called

func (*MockBlockStats) SetBlockStats

func (m *MockBlockStats) SetBlockStats(stats BlockStats) *MockBlockStats

SetBlockStats sets the return value for GetBlockStats()

func (*MockBlockStats) SetPercentile

func (m *MockBlockStats) SetPercentile(percentile int, duration time.Duration) *MockBlockStats

SetPercentile sets the return value for the next call to GetWindowBlockTimePercentile with the given percentile

func (*MockBlockStats) SetWindowBlockStats

func (m *MockBlockStats) SetWindowBlockStats(stats BlockStats) *MockBlockStats

SetWindowBlockStats sets the return value for GetWindowBlockStats()

type OverallPerformance

type OverallPerformance struct {
	TotalRuntime      time.Duration `json:"total_runtime"`
	TotalTransactions uint64        `json:"total_transactions"`
	AverageTPS        float64       `json:"average_tps"`
	MaxTPS            float64       `json:"max_tps"`
}

OverallPerformance represents comprehensive performance summary

type OverallTPS

type OverallTPS struct {
	Current float64 `json:"current"`
	Max     float64 `json:"max"`
}

OverallTPS represents overall throughput metrics

type Stats

type Stats struct {
	StartTime         time.Time
	TotalTxs          uint64
	TxCounts          map[string]map[string]uint64 // [scenario][endpoint] -> count
	EndpointStats     map[string]EndpointStats
	OverallMaxTPS     float64
	OverallCurrentTPS float64
	BlockStats        *BlockStats // Block-related statistics
}

Stats represents comprehensive load test statistics

func (*Stats) FormatStats

func (s *Stats) FormatStats() string

FormatStats returns a formatted string representation of the statistics

type TPSWindow

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

TPSWindow tracks transactions in a sliding 10-second window

type UserLatencyTracker

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

UserLatencyTracker tracks user latency by analyzing block transactions

func NewUserLatencyTracker

func NewUserLatencyTracker(interval time.Duration) *UserLatencyTracker

NewUserLatencyTracker creates a new user latency tracker

func (*UserLatencyTracker) Run

func (ult *UserLatencyTracker) Run(ctx context.Context, endpoint string) error

Run starts the user latency tracking loop

type WindowStats

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

WindowStats tracks metrics for the current reporting window

Jump to

Keyboard shortcuts

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