Change percentiles field names as they were misleading
Also removes the total latencies field from Metrics as it is not useful.
This commit is contained in:
@@ -118,7 +118,7 @@ Specifies the kind of report to be generated. It defaults to text.
|
||||
##### text
|
||||
```
|
||||
Requests [total] 1200
|
||||
Latencies [mean, max, 95, 99] 223.340085ms, 7.788103259s, 326.913687ms, 416.537743ms
|
||||
Latencies [mean, 95, 99, max] 223.340085ms, 326.913687ms, 416.537743ms, 7.788103259s
|
||||
Bytes In [total, mean] 3714690, 3095.57
|
||||
Bytes Out [total, mean] 0, 0.00
|
||||
Success [ratio] 55.42%
|
||||
@@ -136,11 +136,10 @@ Get http://localhost:6060: http: can't write HTTP request on broken connection
|
||||
```json
|
||||
{
|
||||
"latencies": {
|
||||
"total": 10912384376645,
|
||||
"max": 12604629125,
|
||||
"mean": 9093653647,
|
||||
"mean_95": 12553709381,
|
||||
"mean_99": 12604629125
|
||||
"95th": 12553709381,
|
||||
"99th": 12604629125,
|
||||
"max": 12604629125
|
||||
},
|
||||
"bytes_in": {
|
||||
"total": 782040,
|
||||
|
||||
@@ -11,11 +11,10 @@ import (
|
||||
// that is used for some of the Reporters
|
||||
type Metrics struct {
|
||||
Latencies struct {
|
||||
Total time.Duration `json:"total"`
|
||||
Max time.Duration `json:"max"`
|
||||
Mean time.Duration `json:"mean"`
|
||||
Mean95 time.Duration `json:"mean_95"`
|
||||
Mean99 time.Duration `json:"mean_99"`
|
||||
Mean time.Duration `json:"mean"`
|
||||
P95 time.Duration `json:"95th"` // P95 is the 95th percentile upper value
|
||||
P99 time.Duration `json:"99th"` // P99 is the 99th percentile upper value
|
||||
Max time.Duration `json:"max"`
|
||||
} `json:"latencies"`
|
||||
|
||||
BytesIn struct {
|
||||
@@ -42,12 +41,12 @@ func NewMetrics(results []Result) *Metrics {
|
||||
}
|
||||
errorSet := map[string]struct{}{}
|
||||
quants := quantile.NewTargeted(0.95, 0.99)
|
||||
totalSuccess := 0
|
||||
totalSuccess, totalLatencies := 0, time.Duration(0)
|
||||
|
||||
for _, result := range results {
|
||||
quants.Insert(float64(result.Latency))
|
||||
m.StatusCodes[strconv.Itoa(int(result.Code))]++
|
||||
m.Latencies.Total += result.Latency
|
||||
totalLatencies += result.Latency
|
||||
m.BytesOut.Total += result.BytesOut
|
||||
m.BytesIn.Total += result.BytesIn
|
||||
if result.Latency > m.Latencies.Max {
|
||||
@@ -61,9 +60,9 @@ func NewMetrics(results []Result) *Metrics {
|
||||
}
|
||||
}
|
||||
|
||||
m.Latencies.Mean = time.Duration(float64(m.Latencies.Total) / float64(m.Requests))
|
||||
m.Latencies.Mean95 = time.Duration(quants.Query(0.95))
|
||||
m.Latencies.Mean99 = time.Duration(quants.Query(0.99))
|
||||
m.Latencies.Mean = time.Duration(float64(totalLatencies) / float64(m.Requests))
|
||||
m.Latencies.P95 = time.Duration(quants.Query(0.95))
|
||||
m.Latencies.P99 = time.Duration(quants.Query(0.99))
|
||||
m.BytesIn.Mean = float64(m.BytesIn.Total) / float64(m.Requests)
|
||||
m.BytesOut.Mean = float64(m.BytesOut.Total) / float64(m.Requests)
|
||||
m.Success = float64(totalSuccess) / float64(m.Requests)
|
||||
|
||||
@@ -23,11 +23,10 @@ func TestNewMetrics(t *testing.T) {
|
||||
}
|
||||
|
||||
for field, values := range map[string][]time.Duration{
|
||||
"Latencies.Total": []time.Duration{m.Latencies.Total, 150 * time.Millisecond},
|
||||
"Latencies.Mean": []time.Duration{m.Latencies.Mean, 50 * time.Millisecond},
|
||||
"Latencies.Mean95": []time.Duration{m.Latencies.Mean95, 30 * time.Millisecond},
|
||||
"Latencies.Mean99": []time.Duration{m.Latencies.Mean99, 30 * time.Millisecond},
|
||||
"Latencies.Max": []time.Duration{m.Latencies.Max, 100 * time.Millisecond},
|
||||
"Latencies.Max": []time.Duration{m.Latencies.Max, 100 * time.Millisecond},
|
||||
"Latencies.Mean": []time.Duration{m.Latencies.Mean, 50 * time.Millisecond},
|
||||
"Latencies.P95": []time.Duration{m.Latencies.P95, 30 * time.Millisecond},
|
||||
"Latencies.P99": []time.Duration{m.Latencies.P99, 30 * time.Millisecond},
|
||||
} {
|
||||
if values[0] != values[1] {
|
||||
t.Errorf("%s: want: %s, got: %s", field, values[1], values[0])
|
||||
|
||||
@@ -19,8 +19,8 @@ func ReportText(results []Result) ([]byte, error) {
|
||||
|
||||
w := tabwriter.NewWriter(out, 0, 8, 2, '\t', tabwriter.StripEscape)
|
||||
fmt.Fprintf(w, "Requests\t[total]\t%d\n", m.Requests)
|
||||
fmt.Fprintf(w, "Latencies\t[mean, max, 95, 99]\t%s, %s, %s, %s\n",
|
||||
m.Latencies.Mean, m.Latencies.Max, m.Latencies.Mean95, m.Latencies.Mean99)
|
||||
fmt.Fprintf(w, "Latencies\t[mean, 95, 99, max]\t%s, %s, %s, %s\n",
|
||||
m.Latencies.Mean, m.Latencies.P95, m.Latencies.P99, m.Latencies.Max)
|
||||
fmt.Fprintf(w, "Bytes In\t[total, mean]\t%d, %.2f\n", m.BytesIn.Total, m.BytesIn.Mean)
|
||||
fmt.Fprintf(w, "Bytes Out\t[total, mean]\t%d, %.2f\n", m.BytesOut.Total, m.BytesOut.Mean)
|
||||
fmt.Fprintf(w, "Success\t[ratio]\t%.2f%%\n", m.Success*100)
|
||||
|
||||
Reference in New Issue
Block a user