Does anyone have any thoughts on whether it would be feasible/desirable to
be able to report allocs/op as a decimal in benchmarks? There must be many
small functions out there which allocate at uneven, sub b.N, rates.
Currently they are hidden/hard to reason about.
On Sunday, 4 September 2016 2
Thanks Peter,
Your observation cracked the mystery for me. There were two things that
were causing me confusion.
1: That we were not observing any allocations at all, even though the map/s
must be allocating.
2: That one of these tests would allocate anything at all, while the other
allocates
Francis,
And, of course,
keyVals := make([]string, b.N*10)
// ...
for _, key := range keyVals {
setTwo(s, key)
}
should be
keyVals := make([]string, b.N)
// ...
for _, key := range keyVals {
setTwo(s, key)
}
or
s /b.N*10/b.N/g
Peter
On Fri, Sep 2, 2016 at 4:38 PM, peterGo w
Francis,
First, fix any bugs.
For example, "The benchmark function must run the target code b.N times."
https://golang.org/pkg/testing/
Therefore,
keyVals := make([]string, b.N*10)
// ...
for _, key := range keyVals {
setOne(s, key)
}
should be
keyVals := make([]string, b.N)
// ...