Is it possible that gc automatically replaces the "_" with a hidden 
declared package-level variable?

On Wednesday, June 23, 2021 at 1:14:36 AM UTC-4 tapi...@gmail.com wrote:

> 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/20759035-49f9-406c-bbe5-8b98801c3090n%40googlegroups.com.

Reply via email to