Skip to content

Instantly share code, notes, and snippets.

@dvirsky
Created January 9, 2016 22:59
Show Gist options
  • Save dvirsky/abef517c31829c0ffe72 to your computer and use it in GitHub Desktop.
Save dvirsky/abef517c31829c0ffe72 to your computer and use it in GitHub Desktop.
package foo
import (
"testing"
)
type Foo struct {
a string
b int
c float32
d string
e string
aa string
bb int
cc float32
dd string
ed string
aaa string
bbb int
ccc float32
ddd string
ede string
}
func (f Foo) Do() {
}
func (f *Foo) DoP() {
}
func BenchmarkValue(b *testing.B) {
f := Foo{
"foo",
1,
2,
"bar",
"baz",
"foo",
1,
2,
"bar",
"baz",
"foo",
1,
2,
"bar",
"baz",
}
for i := 0; i < b.N; i++ {
f.Do()
}
}
func BenchmarkPointer(b *testing.B) {
f := &Foo{"foo",
1,
2,
"bar",
"baz",
"foo",
1,
2,
"bar",
"baz",
"foo",
1,
2,
"bar",
"baz"}
for i := 0; i < b.N; i++ {
f.DoP()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment