왜 ps 와 top 은 서로 다른 cpu 사용률을 보여주는 것일까? 결론부터 이야기하면, top 과 ps 는 서로 다른 명령어이다.

top 은 우리가 흔히 생각하는 cpu 사용률을 보여주는 것이 맞지만, ps 는 약간 다른 부분을 보여준다. 다음은 ps 명령어의 man page 의 일부분이다.

CPU usage is currently expressed as the percentage of time spent running during the entire lifetime of a process.  This is not ideal, and it does not conform to the standards that ps otherwise conforms to.  CPU usage is unlikely to add up to exactly 100%.

즉, ps 명령어는 프로세스가 동작한 전체 시간에서의 cpu 점유율을 나타낸다는 것이다. 따라서 지정된 시간 동안에서의 cpu 점유율을 보여주는 top 과는 서로 다른 결과를 보여줄 수 밖에 없는 것이다.

top 은 모니터링, ps 는 스냅샷으로 생각을 하면 이해가 쉬워진다.

참조: http://unix.stackexchange.com/questions/58539/top-and-ps-not-showing-the-same-cpu-result

Tags: , , ,

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.