2024-12-04 16:40:52 -06:00
|
|
|
package lib
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2024-12-04 17:26:34 -06:00
|
|
|
// PerformanceMetrics represents a thread-safe container for tracking
|
|
|
|
// performance statistics during load testing
|
2024-12-04 16:40:52 -06:00
|
|
|
type PerformanceMetrics struct {
|
|
|
|
Mu sync.Mutex
|
|
|
|
TotalRequests int32
|
|
|
|
TotalResponses int32
|
|
|
|
TotalLatency time.Duration
|
|
|
|
MaxLatency time.Duration
|
|
|
|
MinLatency time.Duration
|
|
|
|
ResponseCounters map[int]int32
|
2024-12-04 17:45:27 -06:00
|
|
|
RequestLatencies []RequestMetric
|
|
|
|
}
|
|
|
|
|
|
|
|
// RequestMetric represents a single request's performance metrics
|
|
|
|
type RequestMetric struct {
|
|
|
|
Timestamp time.Time
|
|
|
|
Duration time.Duration
|
|
|
|
StatusCode int
|
|
|
|
Verb string
|
2024-12-04 16:40:52 -06:00
|
|
|
}
|
|
|
|
|
2024-12-04 17:26:34 -06:00
|
|
|
// RequestError represents a detailed error that occurs during an HTTP request
|
2024-12-04 16:40:52 -06:00
|
|
|
type RequestError struct {
|
|
|
|
Verb string
|
|
|
|
URL string
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
2024-12-04 17:26:34 -06:00
|
|
|
// RequestPattern defines the characteristics of requests to be sent during load testing
|
2024-12-04 16:40:52 -06:00
|
|
|
type RequestPattern struct {
|
|
|
|
Verb string
|
|
|
|
Percentage float64
|
|
|
|
Sequence int
|
|
|
|
}
|