a Q on measuring system performance.
Peter Jeremy
PeterJeremy at optushome.com.au
Fri Mar 25 11:03:46 PST 2005
On Thu, 2005-Mar-24 23:21:54 -0800, Yan Yu wrote:
>I am trying to measure the overhead added by these instrumentation code.
>my plan is:
> in my user space program, i have something like the following:
>--------------------------------------------
> gettimeofday(&prev_time, NULL);
> for (i=0; i< 1000; i++)
> {
> fd = fopen("tmp", "r" );
> if (fd == NULL)
> {
> break;
> }
> cnt ++;
> }
>
> gettimeofday(&cur_time, NULL);
> t_lapse= misc_tv_offset( &cur_time, &prev_time );
>
>----------------------------------------------------
That approach is reasonable (but the above code leaks file
descriptors) . You might want to increase 1000 and/or use rdtsc() for
timing depending on your accuracy/resolution requirements.
>I would run this for the unmodified kernel, and instrumented kernel.
>compare the t_lapse, my concern is that t_lapse includes context switch
>time when the user process is taken out of run queue.
So would gprof. And gprof has much higher overheads and a granularity
of 10usec.
--
Peter Jeremy
More information about the freebsd-hackers
mailing list