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

Function BenchmarkPlot

lib/plot/plot_test.go:132–165  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

130}
131
132func BenchmarkPlot(b *testing.B) {
133 b.StopTimer()
134 // Build result set
135 rs := make(vegeta.Results, 50000000)
136 for began, i := time.Now(), 0; i < cap(rs); i++ {
137 rs[i] = vegeta.Result{
138 Attack: "foo",
139 Code: uint16(i % 600),
140 Latency: 50 * time.Millisecond,
141 Timestamp: began.Add(time.Duration(i) * 50 * time.Millisecond),
142 }
143 if i%5 == 0 {
144 rs[i].Error = "Error"
145 }
146 }
147
148 plot := New(
149 Title("Vegeta Plot"),
150 Downsample(5000),
151 Label(ErrorLabeler),
152 )
153
154 b.Run("Add", func(b *testing.B) {
155 for i := 0; i < b.N; i++ {
156 _ = plot.Add(&rs[i%len(rs)])
157 }
158 })
159
160 b.Run("WriteTo", func(b *testing.B) {
161 for i := 0; i < b.N; i++ {
162 _, _ = plot.WriteTo(io.Discard)
163 }
164 })
165}

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
TitleFunction · 0.85
LabelFunction · 0.85
WriteToMethod · 0.80
DownsampleFunction · 0.70
AddMethod · 0.65

Tested by

no test coverage detected