Is there a C function that can calculate the CPU usage time for a process? or is there a way to calculate the same?
Thanks,
Anoop.
Printable View
Is there a C function that can calculate the CPU usage time for a process? or is there a way to calculate the same?
Thanks,
Anoop.
There are various profilers available......some compilers come with themQuote:
Originally posted by Unregistered
Is there a C function that can calculate the CPU usage time for a process? or is there a way to calculate the same?
Thanks,
Anoop.
>Is there a C function that can calculate the CPU usage time for a process?
But keep in mind that a profiler is far more accurate. If your functions are quick then you will time them as 0 with this method.Code:clock_t time_function ( void (*func_to_time)(void) )
{
clock_t start, end;
start = clock();
/*
** Do some process.
*/
func_to_time();
end = clock();
return end - start;
}
-Prelude
Hey Prelude!: )...where can one find the definition of the clock() func and the data type clock_t?
cheers!
<time.h> or <ctime> if you are c++ inclined!Quote:
Originally posted by Unregistered
Hey Prelude!: )...where can one find the definition of the clock() func and the data type clock_t?
cheers!