I would like to display time elapsed.
So for that I need to get the CPU time.How to get the CPU time?
I would like to display time elapsed.
So for that I need to get the CPU time.How to get the CPU time?
Hi,
One thing is CPU time and another is total time. The CPU time is the time that your process have been into the CPU to execute the code. The total time includes the time that your process is out of the CPU because of Operating System schedeuler.
To get total time use the class QTime and take a look at int QTime::msecsTo(const QTime & t) constIf your would get the CPU time you need to use OS specific code.
Òscar Llarch i Galán
It depends on what you want.
The CPU time will get you the exact time that your process is on the CPU. The second includes the time that your process is not into the CPU.
Imagine that there is a process that is using 90% of CPU, so your program will get a time execution of 5 seconds, but really it have been on CPU only 1 second.
The real time that you or the user will see is the total time. The other time can be used when trying to improve the performance of your code.
Òscar Llarch i Galán
Bookmarks