merged from gramsrv upstream
This commit is contained in:
parent
79c64ee916
commit
21a0856587
651 changed files with 54774 additions and 4590 deletions
21
cmd/telesrv/process_cpu_windows.go
Normal file
21
cmd/telesrv/process_cpu_windows.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
//go:build windows
|
||||
|
||||
package main
|
||||
|
||||
import "golang.org/x/sys/windows"
|
||||
|
||||
func processCPUSeconds() (float64, bool) {
|
||||
handle, err := windows.GetCurrentProcess()
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
var creation, exit, kernel, user windows.Filetime
|
||||
if err := windows.GetProcessTimes(handle, &creation, &exit, &kernel, &user); err != nil {
|
||||
return 0, false
|
||||
}
|
||||
ns := kernel.Nanoseconds() + user.Nanoseconds()
|
||||
if ns < 0 {
|
||||
return 0, false
|
||||
}
|
||||
return float64(ns) / 1e9, true
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue