Question

In http://www.gnu.org/software/libc/manual/html_node/Setting-an-Alarm.html, it is told that:
- A real-time timer that counts elapsed time --> CPU time + IO time + waiting time
- A virtual timer that counts processor time used by the process. --> CPU time
- A profiling timer that counts both processor time used by the process, and processor time spent in system calls on behalf of the process. --> also CPU time
What is the difference between virtual and profiling timers?

Was it helpful?

Solution

What is the difference between virtual and profiling timers?

The difference is that the virtual timer measures only the time the process itself uses, while the profiling timer measures the time the process itself uses as well as time spent in system calls for the process.

Say you've got a piece of code that makes some system calls, and you want to see if you can make the code run more quickly. If the time reported by both the virtual timer and the profiling timer are very close to each other, then your process is spending most of its time in its own code, which means that you might be able to speed up the process by changing its code. On the other hand, if the time reported by the profiling timer is 100x that of the virtual timer, the process is spending most of its time in system calls. In this case, if you want to speed up the process you'll need to reduce the number of system calls or at least change the way the system calls are used.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top