Skip to content

Instantly share code, notes, and snippets.

@simcap
Created May 22, 2019 14:11
Show Gist options
  • Save simcap/3643463262fb7227ffa6c2490b72a64d to your computer and use it in GitHub Desktop.
Save simcap/3643463262fb7227ffa6c2490b72a64d to your computer and use it in GitHub Desktop.
func logProcessUsage(cmd *exec.Cmd) {
switch v := cmd.ProcessState.SysUsage().(type) {
case *syscall.Rusage:
log.Printf("%s: mem=%.2fM, systime=%s, usertime=%s", cmd.Path, float64(v.Maxrss/1000), cmd.ProcessState.SystemTime(), cmd.ProcessState.UserTime())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment