MCPcopy
hub / github.com/tsenart/vegeta / Add

Method Add

lib/metrics.go:50–86  ·  view source on GitHub ↗

Add implements the Add method of the Report interface by adding the given Result to Metrics.

(r *Result)

Source from the content-addressed store, hash-verified

48// Add implements the Add method of the Report interface by adding the given
49// Result to Metrics.
50func (m *Metrics) Add(r *Result) {
51 m.init()
52
53 m.Requests++
54 m.StatusCodes[strconv.Itoa(int(r.Code))]++
55 m.BytesOut.Total += r.BytesOut
56 m.BytesIn.Total += r.BytesIn
57
58 m.Latencies.Add(r.Latency)
59
60 if m.Earliest.IsZero() || m.Earliest.After(r.Timestamp) {
61 m.Earliest = r.Timestamp
62 }
63
64 if r.Timestamp.After(m.Latest) {
65 m.Latest = r.Timestamp
66 }
67
68 if end := r.End(); end.After(m.End) {
69 m.End = end
70 }
71
72 if r.Code >= 200 && r.Code < 400 {
73 m.success++
74 }
75
76 if r.Error != "" {
77 if _, ok := m.errors[r.Error]; !ok {
78 m.errors[r.Error] = struct{}{}
79 m.Errors = append(m.Errors, r.Error)
80 }
81 }
82
83 if m.Histogram != nil {
84 m.Histogram.Add(r)
85 }
86}
87
88// Close implements the Close method of the Report interface by computing
89// derived summary metrics which don't need to be run on every Add call.

Callers 4

decodeMetricsFunction · 0.95
TestAttackDurationFunction · 0.95
TestMetrics_AddFunction · 0.95
BenchmarkMetricsFunction · 0.95

Calls 3

initMethod · 0.95
EndMethod · 0.80
AddMethod · 0.65

Tested by 4

decodeMetricsFunction · 0.76
TestAttackDurationFunction · 0.76
TestMetrics_AddFunction · 0.76
BenchmarkMetricsFunction · 0.76