The code:

package concat

import (
    "testing"
)

var s33 = []byte{32: 'b'}
var a = string(s33)


func Benchmark_e_33(b *testing.B) {
    for i := 0; i < b.N; i++ {
        _ = a + a // a + a does not escape
    }
}

"go test -gcflags=-m" shows: a + a does not escape
but "go test -bench=. -benchmem" shows:
Benchmark_e_33-4       16544446            68.35 ns/op          80 B/op    
       1 allocs/op

In my impression, memory blocks allocated on stack are not counted in the 
bench result.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/46602929-cb49-45da-91f5-12bc343145e8n%40googlegroups.com.

Reply via email to