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` <all profile files here>

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 <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Josh Bleecher Snyder 2019-03-10 18:34:09 -07:00
Родитель a10017ccd2
Коммит 4ccd092f47
1 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -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)
}
}