throughput

package
v1.0.0-alpha.21 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package throughput provides a high-throughput E2E scenario for performance profiling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CPUAnalysis

type CPUAnalysis struct {
	TopFunctions []FunctionSample `json:"top_functions"`
	TotalSamples int              `json:"total_samples"`
	RawOutput    string           `json:"raw_output,omitempty"`
}

CPUAnalysis holds parsed CPU profile data.

type Config

type Config struct {
	// Message configuration
	MessageCount int `json:"message_count"` // Total messages to send (default: 10000)
	MessageRate  int `json:"message_rate"`  // Messages per second, 0 = unlimited
	MessageSize  int `json:"message_size"`  // Approximate bytes per message (default: 256)

	// Profile configuration
	ProfileDuration int    `json:"profile_duration"` // CPU profile seconds (default: 30)
	ProfileDir      string `json:"profile_dir"`      // Directory for profile output

	// Query load configuration
	QueryConcurrency int           `json:"query_concurrency"` // Parallel query goroutines (default: 10)
	QueryDuration    time.Duration `json:"query_duration"`    // Sustain queries for (default: 15s)
	GraphQLURL       string        `json:"graphql_url"`       // Gateway GraphQL endpoint

	// Extended profiling
	ProfileAll bool `json:"profile_all"` // Capture block + mutex profiles too

	// Validation
	ValidationTimeout time.Duration `json:"validation_timeout"`  // Max wait for processing
	MinProcessedRatio float64       `json:"min_processed_ratio"` // Min ratio of messages processed (default: 0.9)
}

Config holds configuration for the throughput scenario.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns sensible defaults for throughput testing.

type FunctionSample

type FunctionSample struct {
	Name      string  `json:"name"`
	FlatPct   float64 `json:"flat_pct"`
	CumPct    float64 `json:"cum_pct"`
	FlatValue string  `json:"flat_value"`
	CumValue  string  `json:"cum_value"`
}

FunctionSample represents a single function in a pprof text output.

type GoroutineAnalysis

type GoroutineAnalysis struct {
	TotalCount int      `json:"total_count"`
	TopStacks  []string `json:"top_stacks,omitempty"`
	RawOutput  string   `json:"raw_output,omitempty"`
}

GoroutineAnalysis holds parsed goroutine profile data.

type HeapAnalysis

type HeapAnalysis struct {
	TopAllocators []FunctionSample `json:"top_allocators"`
	HeapInUseMB   float64          `json:"heap_in_use_mb"`
	HeapAllocMB   float64          `json:"heap_alloc_mb"`
	RawOutput     string           `json:"raw_output,omitempty"`
}

HeapAnalysis holds parsed heap profile data.

type ProfileAnalysis

type ProfileAnalysis struct {
	CPU        *CPUAnalysis       `json:"cpu,omitempty"`
	Heap       *HeapAnalysis      `json:"heap,omitempty"`
	Goroutines *GoroutineAnalysis `json:"goroutines,omitempty"`
	Summary    string             `json:"summary"`
	Warnings   []string           `json:"warnings,omitempty"`
}

ProfileAnalysis holds the parsed results from all captured pprof profiles.

type QueryLoadResult

type QueryLoadResult struct {
	TotalQueries    int                       `json:"total_queries"`
	QueriesPerSec   float64                   `json:"queries_per_sec"`
	Duration        time.Duration             `json:"duration"`
	ByType          map[string]QueryTypeStats `json:"by_type"`
	ErrorCount      int                       `json:"error_count"`
	NotFoundCount   int                       `json:"not_found_count"`
	NotFoundDetails []string                  `json:"not_found_details,omitempty"` // unique not-found messages
	ErrorDetails    []string                  `json:"error_details,omitempty"`     // unique infra error messages
	P50LatencyMs    float64                   `json:"p50_latency_ms"`
	P95LatencyMs    float64                   `json:"p95_latency_ms"`
	P99LatencyMs    float64                   `json:"p99_latency_ms"`
}

QueryLoadResult holds aggregate results from the query load phase.

type QueryTypeStats

type QueryTypeStats struct {
	Count        int     `json:"count"`
	Errors       int     `json:"errors"`
	NotFound     int     `json:"not_found"`
	AvgLatencyMs float64 `json:"avg_latency_ms"`
	TotalMs      float64 `json:"-"` // accumulator
}

QueryTypeStats holds per-query-type statistics.

type Scenario

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

Scenario sends high volumes of messages for performance profiling.

func NewScenario

func NewScenario(metricsURL, udpAddr string, cfg *Config) *Scenario

NewScenario creates a new throughput scenario.

func (*Scenario) Description

func (s *Scenario) Description() string

Description returns the scenario description.

func (*Scenario) Execute

func (s *Scenario) Execute(ctx context.Context) (*scenarios.Result, error)

Execute runs the throughput test.

func (*Scenario) Name

func (s *Scenario) Name() string

Name returns the scenario name.

func (*Scenario) Setup

func (s *Scenario) Setup(ctx context.Context) error

Setup prepares the scenario.

func (*Scenario) Teardown

func (s *Scenario) Teardown(_ context.Context) error

Teardown cleans up after the scenario.

type SendResult

type SendResult struct {
	MessagesSent int
	Duration     time.Duration
	Rate         float64 // messages per second
}

SendResult holds the results of the send phase.

Jump to

Keyboard shortcuts

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