1
0
mirror of https://github.com/golang/go synced 2024-11-11 23:40:22 -07:00

Force full sampling of memory allocations only for MemProf

Also reduce the number of allocations in this testcase, as it no
longer requires many allocations to trigger sampling.
This commit is contained in:
Raul Silvera 2019-01-17 16:03:55 -08:00
parent 7d34aff8f1
commit 471f747af8

View File

@ -14,8 +14,6 @@ import (
)
func init() {
// Force heap sampling for determinism.
runtime.MemProfileRate = 1
register("MemProf", MemProf)
}
@ -23,7 +21,10 @@ var memProfBuf bytes.Buffer
var memProfStr string
func MemProf() {
for i := 0; i < 1000; i++ {
// Force heap sampling for determinism.
runtime.MemProfileRate = 1
for i := 0; i < 10; i++ {
fmt.Fprintf(&memProfBuf, "%*d\n", i, i)
}
memProfStr = memProfBuf.String()