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:
parent
7d34aff8f1
commit
471f747af8
7
src/runtime/testdata/testprog/memprof.go
vendored
7
src/runtime/testdata/testprog/memprof.go
vendored
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user