mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
compilebench: handle missing MemStats more gracefully
Reporting MemStats requires the legacy profile format (see golang/go#18641). This CL detects when it couldn't get the MemStats from the profile and reports this, rather than reporting 0 allocs. Change-Id: Ib621ad975290cf05835fafa81e8e47762d82a519 Reviewed-on: https://go-review.googlesource.com/c/tools/+/175802 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
60140f0909
commit
e31d36578a
@ -437,6 +437,7 @@ func runBuildCmd(name string, count int, dir, tool string, args []string) error
|
||||
}
|
||||
end := time.Now()
|
||||
|
||||
haveAllocs := false
|
||||
var allocs, allocbytes int64
|
||||
if *flagAlloc || *flagMemprofile != "" {
|
||||
out, err := ioutil.ReadFile(dir + "/_compilebench_.memprof")
|
||||
@ -452,6 +453,7 @@ func runBuildCmd(name string, count int, dir, tool string, args []string) error
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
haveAllocs = true
|
||||
switch f[1] {
|
||||
case "TotalAlloc":
|
||||
allocbytes = val
|
||||
@ -459,6 +461,9 @@ func runBuildCmd(name string, count int, dir, tool string, args []string) error
|
||||
allocs = val
|
||||
}
|
||||
}
|
||||
if !haveAllocs {
|
||||
log.Println("missing stats in memprof (golang.org/issue/18641)")
|
||||
}
|
||||
|
||||
if *flagMemprofile != "" {
|
||||
outpath := *flagMemprofile
|
||||
@ -491,7 +496,7 @@ func runBuildCmd(name string, count int, dir, tool string, args []string) error
|
||||
userns := cmd.ProcessState.UserTime().Nanoseconds()
|
||||
|
||||
fmt.Printf("%s 1 %d ns/op %d user-ns/op", name, wallns, userns)
|
||||
if *flagAlloc {
|
||||
if haveAllocs {
|
||||
fmt.Printf(" %d B/op %d allocs/op", allocbytes, allocs)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user