How to measure performance inside Kernel?

Peter Senna Tschudin peter.senna at gmail.com
Fri Feb 10 16:47:37 EST 2012


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

On Thu, Feb 9, 2012 at 10:58 AM, Peter Senna Tschudin
<peter.senna at gmail.com> wrote:
> Dear list,
>
> I'm looking for a way to compare the performance of two different
> codes inside Kernel. I was able to do some comparison on user land but
> I want to test the specific portion of code inside Kernel.

-- 
Peter Senna Tschudin
peter.senna at gmail.com
gpg id: 48274C36



More information about the Kernelnewbies mailing list