Hi Srinivas,
If I get you right you're asking me to use gettimeofday() again. I
heard that using user space routines like gettimeofday() gives you
unstable results. This is because kernel scheduler might suspend out
your function anytime.. If this is so, I would like a kernel space
alternative. Or maybe gprof as Gaurav suggested.
Manav
Srinivas G. wrote:
MK Wrote:
Greetings,
Hi I wanted to profile time taken by a particular funtion in an
application. I had been using gettimeofday() till now and calculating
the
time diff b/w the call of the function and its return.
I read in a forum that even though it shows a resolution of
microseconds
it is incorrect. The true resolution is only the order of
microseconds. Is
the microsecond part really unreliable (fake) ??
How do I profile my code other wise ?
Thanks in advance,
Dear MK,
You can approach the following method to get the exact time deference
b/w the call of the function and its return.
static unsigned int ms = 0;
static struct timeval start_tm,cur_tm;
do_gettimeofday(&start_tm);
ms = (cur_tm.tv_sec*1000000+cur_tm.tv_usec)-
(start_tm.tv_sec*1000000+start_tm.tv_usec) + 1;
printk("%10ld.%3ld ms",ms/1000, ms%1000);
Call the function
do_gettimeofday( &cur_tm );
ms = (cur_tm.tv_sec*1000000+cur_tm.tv_usec)-
(start_tm.tv_sec*1000000+start_tm.tv_usec) + 1;
printk("%10ld.%3ld ms",ms/1000, ms%1000);
Regards,
Srinivas G
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/