title: What does allocs/op and B/op mean in go benchmark?
body: <p>When I run my benchmarks with <code>go test -v -bench=. -benchmem</code>, I see the following results.</p>
  
  <pre><code>f1     10000        120860 ns/op        2433 B/op         28 allocs/op
  f2     10000        120288 ns/op        2288 B/op         26 allocs/op
  </code></pre>
  
  <p>Based on my understanding:</p>
  
  <ol>
  <li><code>10000</code> is the number of iterations <code>for i := 0; i &lt; b.N; i++ {</code>.  </li>
  <li><code>XXX ns/op</code> is approximate time it took for one iteration to complete</li>
  </ol>
  
  <p>But even after <a href="https://golang.org/pkg/testing/">reading the docs</a>, I can not find out what <code>B/op</code> and <code>allocs/op</code> mean.</p>
  
  <hr>
  
  <p>My guess is that allocs/op has something to do with garbage collection and memory allocation (the less the better).</p>
  
  <p>Can anyone give a nice explanation of the meaning of these values. Also it would be nice to know why do the go up and main steps to reduce them (I realize this is test specific, but may be there are some universal hints that work in many cases)</p>