Skip to content

Instantly share code, notes, and snippets.

@bmizerany
Created October 23, 2012 19:05
Show Gist options
  • Save bmizerany/3940889 to your computer and use it in GitHub Desktop.
Save bmizerany/3940889 to your computer and use it in GitHub Desktop.
benchmark repro for empty memprofile output
// 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