Skip to content

Commit

Permalink
Ensure to show all metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
nakabonne committed Sep 15, 2020
1 parent 7fa23dd commit 2b87b7c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 23 deletions.
67 changes: 45 additions & 22 deletions attacker/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,55 @@ import (
// Metrics wraps "vegeta.Metrics" to avoid dependency on it.
// TODO: Add more fields
type Metrics struct {
Latencies LatencyMetrics `json:"latencies"`
}

type LatencyMetrics struct {
Total time.Duration `json:"total"`
Mean time.Duration `json:"mean"`
P50 time.Duration `json:"50th"`
P90 time.Duration `json:"90th"`
P95 time.Duration `json:"95th"`
P99 time.Duration `json:"99th"`
Max time.Duration `json:"max"`
Min time.Duration `json:"min"`
// Latencies holds computed request latency metrics.
Latencies vegeta.LatencyMetrics `json:"latencies"`
// Histogram, only if requested
//Histogram *vegeta.Histogram `json:"buckets,omitempty"`
// BytesIn holds computed incoming byte metrics.
BytesIn vegeta.ByteMetrics `json:"bytes_in"`
// BytesOut holds computed outgoing byte metrics.
BytesOut vegeta.ByteMetrics `json:"bytes_out"`
// Earliest is the earliest timestamp in a Result set.
Earliest time.Time `json:"earliest"`
// Latest is the latest timestamp in a Result set.
Latest time.Time `json:"latest"`
// End is the latest timestamp in a Result set plus its latency.
End time.Time `json:"end"`
// Duration is the duration of the attack.
Duration time.Duration `json:"duration"`
// Wait is the extra time waiting for responses from targets.
Wait time.Duration `json:"wait"`
// Requests is the total number of requests executed.
Requests uint64 `json:"requests"`
// Rate is the rate of sent requests per second.
Rate float64 `json:"rate"`
// Throughput is the rate of successful requests per second.
Throughput float64 `json:"throughput"`
// Success is the percentage of non-error responses.
Success float64 `json:"success"`
// StatusCodes is a histogram of the responses' status codes.
StatusCodes map[string]int `json:"status_codes"`
// Errors is a set of unique errors returned by the targets during the attack.
Errors []string `json:"errors"`
}

func newMetrics(m *vegeta.Metrics) *Metrics {
return &Metrics{
Latencies: LatencyMetrics{
Total: m.Latencies.Total,
Mean: m.Latencies.Mean,
P50: m.Latencies.P50,
P90: m.Latencies.P90,
P95: m.Latencies.P95,
P99: m.Latencies.P99,
Max: m.Latencies.Max,
Min: m.Latencies.Min,
},
Latencies: m.Latencies,
//Histogram: m.Histogram,
BytesIn: m.BytesIn,
BytesOut: m.BytesOut,
Earliest: m.Earliest,
Latest: m.Latest,
End: m.End,
Duration: m.Duration,
Wait: m.Wait,
Requests: m.Requests,
Rate: m.Rate,
Throughput: m.Throughput,
Success: m.Success,
StatusCodes: m.StatusCodes,
Errors: m.Errors,
}
}

Expand Down
2 changes: 1 addition & 1 deletion gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ func gridLayout(w *widgets) ([]container.Option, error) {
grid.ColWidthPerc(49, grid.Widget(w.bodyInput, container.Border(linestyle.None))),
),
),
grid.ColWidthPerc(35, grid.Widget(w.reportText, container.Border(linestyle.Light), container.BorderTitle("Report"))),
grid.ColWidthPerc(34, grid.Widget(w.progressDonut, container.Border(linestyle.Light), container.BorderTitle("Progress"))),
grid.ColWidthPerc(35, grid.Widget(w.reportText, container.Border(linestyle.Light), container.BorderTitle("Report"))),
)
raw3 := grid.RowHeightFixed(1,
grid.ColWidthFixed(100, grid.Widget(w.navi, container.Border(linestyle.Light))),
Expand Down

0 comments on commit 2b87b7c

Please sign in to comment.