Logging at the end is improved.
This commit is contained in:
parent
e8f9b1a763
commit
9f746927aa
1 changed files with 140 additions and 141 deletions
|
@ -60,6 +60,7 @@ func UpdateMetrics(duration time.Duration, resp *http.Response, second int) {
|
|||
// Parameters:
|
||||
// - latencies: sorted slice of request durations
|
||||
// - percentile: desired percentile (e.g., 50 for p50, 95 for p95)
|
||||
//
|
||||
// Returns: the duration at the specified percentile
|
||||
func calculatePercentile(latencies []time.Duration, percentile float64) time.Duration {
|
||||
if len(latencies) == 0 {
|
||||
|
@ -86,9 +87,6 @@ func CalculateAndPrintMetrics(startTime time.Time, requestsPerSecond float64, en
|
|||
metrics.Mu.Lock()
|
||||
defer metrics.Mu.Unlock()
|
||||
|
||||
// Save detailed per-request metrics to CSV
|
||||
saveDetailedMetrics()
|
||||
|
||||
// Prepare latencies for percentile calculations
|
||||
latencies := make([]time.Duration, len(metrics.RequestLatencies))
|
||||
for i, metric := range metrics.RequestLatencies {
|
||||
|
@ -160,6 +158,7 @@ func CalculateAndPrintMetrics(startTime time.Time, requestsPerSecond float64, en
|
|||
|
||||
fmt.Println(results)
|
||||
saveReport(results)
|
||||
saveDetailedMetrics()
|
||||
}
|
||||
|
||||
// saveDetailedMetrics writes per-request metrics to a CSV file
|
||||
|
|
Loading…
Add table
Reference in a new issue