mirror of
https://github.com/golang/go
synced 2024-11-18 19:44:46 -07:00
cmd/compilebench: generate separate cpu 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 allows generation of precise profiles, even for fast-compiling packages. Change-Id: I006cf8fad143346b28a646a0b3582cc0f6eec310 Reviewed-on: https://go-review.googlesource.com/39718 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
1cab72a478
commit
ded95f530c
@ -158,7 +158,7 @@ func main() {
|
||||
continue
|
||||
}
|
||||
if runRE == nil || runRE.MatchString(tt.name) {
|
||||
runBuild(tt.name, tt.dir)
|
||||
runBuild(tt.name, tt.dir, i)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -213,7 +213,7 @@ func runSize(name, path string) {
|
||||
}
|
||||
}
|
||||
|
||||
func runBuild(name, dir string) {
|
||||
func runBuild(name, dir string, count int) {
|
||||
switch name {
|
||||
case "BenchmarkStdCmd":
|
||||
runStdCmd()
|
||||
@ -299,7 +299,11 @@ func runBuild(name, dir string) {
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
}
|
||||
if err := ioutil.WriteFile(*flagCpuprofile, out, 0666); err != nil {
|
||||
outpath := *flagCpuprofile
|
||||
if *flagCount != 1 {
|
||||
outpath = fmt.Sprintf("%s_%d", outpath, count)
|
||||
}
|
||||
if err := ioutil.WriteFile(outpath, out, 0666); err != nil {
|
||||
log.Print(err)
|
||||
}
|
||||
os.Remove(pkg.Dir + "/_compilebench_.cpuprof")
|
||||
|
Loading…
Reference in New Issue
Block a user