Add debug http server

This commit is contained in:
世界 2023-04-22 15:58:25 +08:00
parent 98c2c439aa
commit e056d4502b
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
7 changed files with 73 additions and 49 deletions

23
debug_linux.go Normal file
View file

@ -0,0 +1,23 @@
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
}