Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【macOS] Using Glances to obtain the cpu utilization of a specified process in macOS is inaccurate #2736

Open
RLYRLY opened this issue Apr 22, 2024 · 1 comment

Comments

@RLYRLY
Copy link

RLYRLY commented Apr 22, 2024

Environment
OS:macOS 13.6.5 (22G621)
Architecture: ARM64
Psutil version: 5.9.8
Python version: 5.7.7
Type: core, CPU

Description
By using glances to get the cpu utilization of a process, and then using the cpu utilization obtained by the top command or the htop command to verify the results of glances, it is found that the results calculated by glances are completely inconsistent.

Detail
image

htop command: 2.4%

image
glances:0.1%

@nicolargo nicolargo changed the title 【macOS] Using galnces to obtain the cpu utilization of a specified process in macOS is inaccurate 【macOS] Using Glances to obtain the cpu utilization of a specified process in macOS is inaccurate Apr 23, 2024
@nicolargo
Copy link
Owner

Hi @RLYRLY

Glances has a different sampling period than Htop. Htop refresh stats every second. Glances every 2 seconds. As the CPU consumption is very variant, you may have some difference.

Under the wood, Glances uses PsUtil to get the processes information. You may find additional information concerning the algorithm used to compute the CPU consumption here: https://psutil.readthedocs.io/en/latest/#psutil.cpu_times

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants