stress

package
v0.0.0-...-af0ddd0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(cfg *Config) *Client

func (*Client) Run

func (own *Client) Run() string

Run 运行负载测试

func (*Client) WithTransport

func (own *Client) WithTransport(transport *http.Transport) *Client

type Config

type Config struct {
	Method        string            // 请求方法
	URL           string            // 请求URL
	Headers       map[string]string // 请求头
	Body          string            // 请求体
	Concurrent    int               // 并发请求数
	TotalRequests int               // 总请求数
	Timeout       time.Duration     // 请求超时时间
	KeepAlive     bool              // 是否保持连接
}

Config 定义性能测试配置的数据结构

type Latencies

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

func NewLatencies

func NewLatencies() *Latencies

func NewLatenciesWithCapacity

func NewLatenciesWithCapacity(capacity int) *Latencies

func (*Latencies) Append

func (own *Latencies) Append(latency time.Duration)

func (*Latencies) CountTotalLatency

func (own *Latencies) CountTotalLatency() time.Duration

func (*Latencies) GetLatencies

func (own *Latencies) GetLatencies() []time.Duration

func (*Latencies) GetPercentile

func (own *Latencies) GetPercentile(percentile int) time.Duration

func (*Latencies) Len

func (own *Latencies) Len() int

func (*Latencies) Less

func (own *Latencies) Less(i, j int) bool

func (*Latencies) Swap

func (own *Latencies) Swap(i, j int)

type Metrics

type Metrics struct {
	StartTime     time.Time     // 开始时间
	EndTime       time.Time     // 结束事件
	TotalRequests int64         // 总请求数
	SuccessCount  int64         // 成功请求数
	FailedCount   int64         // 失败请求数
	ErrorCount    int64         // 错误总数
	Latencies     *Latencies    // 延迟数据
	StatusCodes   map[int]int64 // 状态码数据
	// contains filtered or unexported fields
}

Metrics 定义性能测试各项指标的数据结构

func NewMetrics

func NewMetrics() *Metrics

NewMetrics 创建一个新的指标

func (*Metrics) Calculate

func (own *Metrics) Calculate()

Calculate 计算性能测试指标

func (*Metrics) Record

func (own *Metrics) Record(statusCode int, latency time.Duration, err error)

Record 记录一次请求结果

func (*Metrics) Report

func (own *Metrics) Report() string

Report 输出性能测试结果

Directories

Path Synopsis
test
base command

Jump to

Keyboard shortcuts

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