Created
January 9, 2016 22:59
-
-
Save dvirsky/abef517c31829c0ffe72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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