time go test -bench=. -memprofile mem.out -benchtime 300snote the argument to benchtime is a Go time.Duration, so you need to append the time unit.
Your BenchmarkAggregation is not running b.N iterations.
The benchmark package will vary b.N until the benchmark function lasts long enough to be timed reliably. The output
Note that the code iterates from 0 to b.N. The benchmark package will vary b.N until the benchmark function lasts long enough to be timed reliably. The output
Note the use of b.N. The benchmark package will vary b.N until the benchmark function lasts long enough to be timed reliably. The output
But that's not correct. Consider for example:
func BenchmarkMakeByteSlice(b *testing.B) {
b := make([]byte, b.N)
b.Log(len(b))
}