From 471f747af845395d458096bea26daa93b91120be Mon Sep 17 00:00:00 2001 From: Raul Silvera Date: Thu, 17 Jan 2019 16:03:55 -0800 Subject: [PATCH] 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. --- src/runtime/testdata/testprog/memprof.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/runtime/testdata/testprog/memprof.go b/src/runtime/testdata/testprog/memprof.go index 7c700af852..7b134bc078 100644 --- a/src/runtime/testdata/testprog/memprof.go +++ b/src/runtime/testdata/testprog/memprof.go @@ -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()