How to properly monitor the CPU usage of a process