You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
We have noticed a significant performance discrepancy when using some of the functions of gopsutil/process on macOS compared to Ubuntu. Precisely, functions related to collecting process information, such as the process name, command line, and CPU usage, are taking considerably longer to execute on macOS than on Ubuntu.
To Reproduce
funcTestOneProcessCPUTime(t*testing.T) {
start:=time.Now()
processes, err:=process.ProcessesWithContext(context.TODO())
require.NoError(t, err)
t.Log("collect processes took: ", time.Since(start))
start=time.Now()
proc:=processes[0]
_, err=proc.Name()
require.NoError(t, err)
t.Log("take the name took: ", time.Since(start))
start=time.Now()
_, err=proc.Cmdline()
require.NoError(t, err)
t.Log("take the cmd line took: ", time.Since(start))
start=time.Now()
_, err=proc.CPUPercent()
require.NoError(t, err)
t.Log("calculate CPU took: ", time.Since(start))
}
ubuntu
=== RUN TestOneProcessCPUTime
scanner_test.go:27: collect processes took: 8.819014ms
scanner_test.go:33: take the name took: 32.28µs
scanner_test.go:38: take the cmd line took: 24.727µs
scanner_test.go:43: calculate CPU took: 110.146µs
macos
=== RUN TestOneProcessCPUTime
scanner_test.go:27: collect processes took: 1.4936445s
scanner_test.go:33: take the name took: 80.5µs
scanner_test.go:38: take the cmd line took: 3.218542ms
scanner_test.go:43: calculate CPU took: 6.1055ms
Expected behavior
The functions should perform similarly across different operating systems. Or, at least, macos performance should be better than the current one.
Environment (please complete the following information):
Windows: [paste the result of ver]
Linux: [paste contents of /etc/os-release and the result of uname -a]
uname -a
Linux fv-az1079-[4](https://github.com/codeready-toolchain/workload-analyzer/actions/runs/10847921906/job/30104001193?pr=27#step:2:5)30 6.5.0-1025-azure #26~22.04.1-Ubuntu SMP Thu Jul 11 22:33:04 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
uname -a
Darwin Mac-172622[4](https://github.com/codeready-toolchain/workload-analyzer/actions/runs/10847921906/job/30104000821?pr=27#step:2:5)488179.local 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:03 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_VMAPPLE arm64
Describe the bug
We have noticed a significant performance discrepancy when using some of the functions of
gopsutil/process
on macOS compared to Ubuntu. Precisely, functions related to collecting process information, such as the process name, command line, and CPU usage, are taking considerably longer to execute on macOS than on Ubuntu.To Reproduce
ubuntu
macos
Expected behavior
The functions should perform similarly across different operating systems. Or, at least, macos performance should be better than the current one.
Environment (please complete the following information):
ver
]/etc/os-release
and the result ofuname -a
]sw_vers
anduname -a
freebsd-version -k -r -u
anduname -a
]uname -a
]Additional context
[Cross-compiling? Paste the command you are using to cross-compile and the result of the corresponding
go env
]The text was updated successfully, but these errors were encountered: