http

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PerfTestHTTP2CMD

func PerfTestHTTP2CMD() *cobra.Command

PerfTestHTTP2CMD creates a new cobra.Command for HTTP/2 performance test.

func PerfTestHTTP3CMD

func PerfTestHTTP3CMD() *cobra.Command

PerfTestHTTP3CMD creates a new cobra.Command for HTTP/3 performance test.

func PerfTestHTTPCMD

func PerfTestHTTPCMD() *cobra.Command

PerfTestHTTPCMD creates a new cobra.Command for HTTP/1.1 performance test.

Types

type HTTPReqParams

type HTTPReqParams struct {
	URL     string
	Method  string
	Headers map[string]string
	Body    []byte
	// contains filtered or unexported fields
}

type PerfTestHTTP

type PerfTestHTTP struct {
	ID int64 // performance test ID

	Client *http.Client
	Params *HTTPReqParams

	Worker        int
	TotalRequests uint64
	Duration      time.Duration

	PushURL           string
	PrometheusJobName string
}

PerfTestHTTP performance test parameters for HTTP

func (*PerfTestHTTP) RunWithFixedDuration

func (p *PerfTestHTTP) RunWithFixedDuration() (*Statistics, error)

RunWithFixedDuration implements performance with a fixed duration.

func (*PerfTestHTTP) RunWithFixedRequestsNum

func (p *PerfTestHTTP) RunWithFixedRequestsNum() (*Statistics, error)

RunWithFixedRequestsNum implements performance with a fixed number of requests.

type Result

type Result struct {
	Duration   time.Duration
	ReqSize    int64
	RespSize   int64
	StatusCode int
	Err        error
}

Result record the results of the request

type Statistics

type Statistics struct {
	PerfTestID int64 `json:"perf_test_id"` // Performance Test ID

	URL    string `json:"url"`    // performed request URL
	Method string `json:"method"` // request method
	Body   string `json:"body"`   // request body (JSON)

	TotalRequests uint64   `json:"total_requests"` // total requests
	TotalDuration float64  `json:"total_duration"` //  total duration (seconds)
	SuccessCount  uint64   `json:"success_count"`  // successful requests (status code 2xx)
	ErrorCount    uint64   `json:"error_count"`    // failed requests (status code not 2xx)
	Errors        []string `json:"errors"`         // error details

	QPS        float64 `json:"qps"`         // requests per second (Throughput)
	AvgLatency float64 `json:"avg_latency"` // average latency (ms)
	P25Latency float64 `json:"p25_latency"` // 25th percentile latency (ms)
	P50Latency float64 `json:"p50_latency"` // 50th percentile latency (ms)
	P95Latency float64 `json:"p95_latency"` // 95th percentile latency (ms)
	MinLatency float64 `json:"min_latency"` // minimum latency (ms)
	MaxLatency float64 `json:"max_latency"` // maximum latency (ms)

	TotalSent     int64 `json:"total_sent"`     // total sent (bytes)
	TotalReceived int64 `json:"total_received"` // total received (bytes)

	StatusCodes map[int]int64 `json:"status_codes"` // status code distribution (count)

	CreatedAt time.Time `json:"created_at"` // created time
}

Statistics statistical data

func (*Statistics) Save

func (s *Statistics) Save(filePath string) error

Save saves the statistics data to a JSON file.

Jump to

Keyboard shortcuts

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