Created
October 23, 2012 19:05
-
-
Save bmizerany/3940889 to your computer and use it in GitHub Desktop.
benchmark repro for empty memprofile output
This file contains hidden or 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
// On an ubuntu VM run as: | |
// GOGC=off ./benchtest.test -test.memprofile=mem.prof -test.run=none -test.bench=. -test.memprofilerate=1 | |
// This will produce a 4k mem.prof with no information in it: | |
// $ go tool pproof ./benchtest.test mem.prof | |
// (prof) top10 | |
// Total: 0.0 MB | |
package benchtest | |
import ( | |
"testing" | |
) | |
type T struct { | |
a int | |
b int | |
} | |
var a []T | |
// allocate something | |
func add() { | |
a = append(a, T{1, 2}) | |
} | |
func BenchmarkTest(b *testing.B) { | |
for i := 0; i < b.N; i ++ { | |
add() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment