Documentation
¶
Index ¶
- type BenchResult
- type HTTPBench
- func (b *HTTPBench) Run() (*BenchResult, error)
- func (b *HTTPBench) SetBody(body []byte) *HTTPBench
- func (b *HTTPBench) SetConcurrency(concurrency int) *HTTPBench
- func (b *HTTPBench) SetDuration(duration time.Duration) *HTTPBench
- func (b *HTTPBench) SetHeaders(headers map[string]string) *HTTPBench
- func (b *HTTPBench) SetMethod(method string) *HTTPBench
- func (b *HTTPBench) SetNumber(number int) *HTTPBench
- func (b *HTTPBench) SetQPSLimit(qps int) *HTTPBench
- func (b *HTTPBench) SetShowProgress(show bool) *HTTPBench
- func (b *HTTPBench) SetTimeout(timeout time.Duration) *HTTPBench
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BenchResult ¶
type BenchResult struct {
URL string
TotalReqs int64
SuccessReqs int64
FailReqs int64
Duration time.Duration
AvgRespTime time.Duration
MinRespTime time.Duration
MaxRespTime time.Duration
ReqsPerSecond float64
BytesPerSecond float64
StatusCodes map[int]int64
}
BenchResult 保存测试结果
type HTTPBench ¶
type HTTPBench struct {
// 基础配置
URL string
Method string
Headers map[string]string
Body []byte
Timeout time.Duration // 每个请求的超时时间
QPSLimit int // QPS限制 (0表示不限制)
// 测试参数
Number int // 总请求数
Concurrency int // 并发数
Duration time.Duration // 测试时长 (如果指定,则忽略Number)
// contains filtered or unexported fields
}
HTTPBench 实现类似 apache bench 的测试功能
func (*HTTPBench) SetConcurrency ¶
SetConcurrency 设置并发数
func (*HTTPBench) SetDuration ¶
SetDuration 设置测试时长
func (*HTTPBench) SetHeaders ¶
SetHeaders 设置请求头
func (*HTTPBench) SetQPSLimit ¶
SetQPSLimit 设置QPS限制
func (*HTTPBench) SetShowProgress ¶
SetShowProgress 设置是否显示进度条
Click to show internal directories.
Click to hide internal directories.