From 4ccd092f47c954d1f5224a270a26c942eecffbe8 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Sun, 10 Mar 2019 18:34:09 -0700 Subject: [PATCH] cmd/compilebench: generate separate mem profiles when using -count When the -count flag is provided, instead of having each run overwrite the previous profile, add a count suffix to the profile filename. Then you can combine the profiles with go tool pprof `go tool -n compile` This was done for CPU profiles in https://golang.org/cl/39718. Change-Id: I4aa66d745fe18088655fc1d9cf3ecf29f68370bb Reviewed-on: https://go-review.googlesource.com/c/tools/+/166523 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Matthew Dempsky --- cmd/compilebench/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/compilebench/main.go b/cmd/compilebench/main.go index 4d3b74ef..915c8adb 100644 --- a/cmd/compilebench/main.go +++ b/cmd/compilebench/main.go @@ -329,7 +329,11 @@ func runBuild(name, dir string, count int) { } if *flagMemprofile != "" { - if err := ioutil.WriteFile(*flagMemprofile, out, 0666); err != nil { + outpath := *flagMemprofile + if *flagCount != 1 { + outpath = fmt.Sprintf("%s_%d", outpath, count) + } + if err := ioutil.WriteFile(outpath, out, 0666); err != nil { log.Print(err) } }