From mboxrd@z Thu Jan 1 00:00:00 1970 From: michi1@michaelblizek.twilightparadox.com (michi1 at michaelblizek.twilightparadox.com) Date: Thu, 9 Feb 2012 19:12:24 +0100 Subject: How to measure performance inside Kernel? In-Reply-To: References: Message-ID: <20120209181223.GA2184@grml> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org Hi! On 10:58 Thu 09 Feb , Peter Senna Tschudin wrote: ... > But I want to repeat the tests on specific portion of code, not on > entire application. Is there a safe way of do something like: > > start_bench ( ?? ); /* start measurement */ > > buf_ptr_end = q->bufs[q->num_buffers]; > > for (buf_ptr = q->bufs[0]; buf_ptr < buf_ptr_end; ++buf_ptr) > buf_ptr->state = VB2_BUF_STATE_DEQUEUED; > > end_bench ( ?? ); /* end measurement */ Yes, you can do this. If you search for a way for time measurement, take a look at include/linux/ktime.h . > And is this the correct approach for testing the performance of > specific portion of Kernel code? Why not? I would be a be worried about how the cpu-cache effects the measurement, especially because your benchmark already showed that a significant time is spent there. -Michi -- programing a layer 3+4 network protocol for mesh networks see http://michaelblizek.twilightparadox.com