From 2b87b7c4edb35b0d7b8b358b975b70751247132a Mon Sep 17 00:00:00 2001 From: nakabonne Date: Tue, 15 Sep 2020 09:17:09 +0900 Subject: [PATCH] Ensure to show all metrics --- attacker/metrics.go | 67 ++++++++++++++++++++++++++++++--------------- gui/gui.go | 2 +- 2 files changed, 46 insertions(+), 23 deletions(-) diff --git a/attacker/metrics.go b/attacker/metrics.go index 0ab6c9f..a040786 100644 --- a/attacker/metrics.go +++ b/attacker/metrics.go @@ -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, } } diff --git a/gui/gui.go b/gui/gui.go index 97cc9a8..7b5d510 100644 --- a/gui/gui.go +++ b/gui/gui.go @@ -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))),