Skip to content

Commit

Permalink
add constant
Browse files Browse the repository at this point in the history
  • Loading branch information
knusbaum committed Dec 2, 2020
1 parent e675025 commit b9ca4c0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/trace/watchdog/cpu_aix.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import (

// As explained above, we will skip 120 bytes into the status file to locate the user CPU time.
const skip = 120
const nsecs_per_sec = 1000000000

func cpuTimeUser(pid int32) (float64, error) {
f, err := os.Open(fmt.Sprintf("/proc/%d/status", pid))
Expand All @@ -101,6 +102,6 @@ func cpuTimeUser(pid int32) (float64, error) {
var userNsecs int32
binary.Read(f, binary.BigEndian, &userSecs)
binary.Read(f, binary.BigEndian, &userNsecs)
time := float64(userSecs) + (float64(userNsecs) / 1000000000)
time := float64(userSecs) + (float64(userNsecs) / nsecs_per_sec)
return time, nil
}

0 comments on commit b9ca4c0

Please sign in to comment.