-----Original Message----- From: kernelnewbies-bounces@kernelnewbies.org [mailto:kernelnewbies- bounces@kernelnewbies.org] On Behalf Of Peter Senna Tschudin Sent: Friday, February 10, 2012 1:48 PM To: kernelnewbies@kernelnewbies.org Subject: Re: How to measure performance inside Kernel?
Dear list,
As Michi suggested, I did some testing with ktime.h, but I found a simpler solution with time.h.
I'm not sure if it is correct, and I would like to have some help... :-)
The code that I'm using for execution time measurement is:
#include <linux/time.h>
getnstimeofday (ts_start); /*stopwatch start*/
for (i = 0; i < q->num_buffers; ++i) q->bufs[i]->state = VB2_BUF_STATE_DEQUEUED;
getnstimeofday (ts_end); /*stopwatch stop*/
diff = timespec_sub(end, begin);
printk ("%lu,", diff.tv_nsec );
Am I doing anything wrong? Can mysterious stuff like out of order execution engine, brake the stopwatch?
The full module code is at: http://goo.gl/cCMIa
Thank you!
Peter
If you didn't disable interrupts before executing the above, the timing of the above loop would include any time spent servicing interrupts. Likewise if there were context switches or soft IRQs running. All would inflate the perceived time to execute your loop. Jeff Haran