Fix pprof URL path

This commit is contained in:
世界 2023-12-27 17:33:07 +08:00
parent ea17c2786d
commit 46c8d6e61f
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 18 additions and 7 deletions

25
debug_unix.go Normal file
View file

@ -0,0 +1,25 @@
//go:build linux || darwin
package box
import (
"runtime"
"syscall"
)
func rusageMaxRSS() float64 {
ru := syscall.Rusage{}
err := syscall.Getrusage(syscall.RUSAGE_SELF, &ru)
if err != nil {
return 0
}
rss := float64(ru.Maxrss)
if runtime.GOOS == "darwin" || runtime.GOOS == "ios" {
rss /= 1 << 20 // ru_maxrss is bytes on darwin
} else {
// ru_maxrss is kilobytes elsewhere (linux, openbsd, etc)
rss /= 1 << 10
}
return rss
}