Trying to use the Histogram support in the vegeta library and calling func (h *Histogram) Add(r *Result) results in a panic due to an index out of range error.
Here is the section of my code where I'm calling func (a *Attacker) Attack and later func (h *Histogram) Add(r *Result):
var metrics vegeta.Metrics
var results vegeta.Results
var histogram vegeta.Histogram
for res := range attacker.Attack(targeter, opts.rate, duration) {
metrics.Add(res)
results.Add(res)
histrogram.Add(res)
}
metrics.Close()
results.Close()
When the above code is executed this is the stacktrace generated:
panic: runtime error: index out of range
goroutine 1 [running]:
panic(0x401e40, 0xc82000a0c0)
/usr/local/go/src/runtime/panic.go:481 +0x3e6
biokdf-bench/vendor/github.com/tsenart/vegeta/lib.(*Histogram).Add(0xc8201120c0, 0xc820148460)
/Users/vendion/gocode/src/biokdf-bench/vendor/github.com/tsenart/vegeta/lib/histogram.go:35 +0x13d
main.runAttack(0xc820100098, 0x4, 0xc8201000a0, 0xf, 0x0, 0xc820112000, 0x3, 0x4)
/Users/vendion/gocode/src/biokdf-bench/main.go:86 +0x705
main.main()
/Users/vendion/gocode/src/biokdf-bench/main.go:55 +0x1f5
Trying to use the Histogram support in the vegeta library and calling
func (h *Histogram) Add(r *Result)
results in a panic due to an index out of range error.Here is the section of my code where I'm calling
func (a *Attacker) Attack
and laterfunc (h *Histogram) Add(r *Result)
:When the above code is executed this is the stacktrace generated:
in my code main.go:86 is
histogram.Add(res)
. Digging through the program with Delve, it looks like the panic is caused by this line https://github.com/tsenart/vegeta/blob/master/lib/histogram.go#L35. This was tested with go version go1.6.2 darwin/amd64