gopsutil
gopsutil copied to clipboard
CPUPercent is Wrong,Percent is OK,but wait one second
Describe the bug
proc, _ := process.NewProcess(int32(pid))
cpuPercent, err := proc.CPUPercent() //get wrong value
proc, _ := process.NewProcess(int32(pid))
cpuPercent, err := proc.Percent(time.Second) //right value, **but wait one second** , same like psutil(python)
### how to get cpuPercent faster ?
To Reproduce
// paste example code reproducing the bug you are reporting
Expected behavior [A clear and concise description of what you expected to happen.]
Environment (please complete the following information):
- [ ] Windows: [paste the result of
ver] - [x] Linux: [paste contents of
/etc/os-releaseand the result ofuname -a] - [ ] Mac OS: [paste the result of
sw_versanduname -a - [ ] FreeBSD: [paste the result of
freebsd-version -k -r -uanduname -a] - [ ] OpenBSD: [paste the result of
uname -a]
Additional context
[Cross-compiling? Paste the command you are using to cross-compile and the result of the corresponding go env]
Could you tell us what is the 'wrong value' with some examples?
I have same problem
cpuPercent, err := proc.CPUPercent(), cpuPercentis wrong.
