We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using go1.5beta3. Using a variadic argument with pointers incurs an allocation for every item even if elements of the variadic argument never escape.
Example:
package foo import "testing" func Foo2(a, b *int) (s int) { for _, v := range []*int{a, b} { s += *v } return s } func FooN(vals ...*int) (s int) { for _, v := range vals { s += *v } return s } func BenchmarkFoo2(b *testing.B) { for i := 0; i < b.N; i++ { var i, j int Foo2(&i, &j) } } func BenchmarkFooN(b *testing.B) { for i := 0; i < b.N; i++ { var i, j int FooN(&i, &j) } }
Currently I see:
$ go test -bench . -benchmem BenchmarkFoo1-4 300000000 5.09 ns/op 0 B/op 0 allocs/op BenchmarkFooN-4 30000000 69.6 ns/op 32 B/op 2 allocs/op
I expect to see 0 allocs/op for BenchmarkFooN.
The text was updated successfully, but these errors were encountered:
CC @dr2chase
Sorry, something went wrong.
CL https://golang.org/cl/15200 mentions this issue.
f7a39a5
No branches or pull requests
Using go1.5beta3.
Using a variadic argument with pointers incurs an allocation for every item even if elements of the variadic argument never escape.
Example:
Currently I see:
I expect to see 0 allocs/op for BenchmarkFooN.
The text was updated successfully, but these errors were encountered: