robbysun at gmail.com
Sun Jan 30 06:22:16 UTC 2011
I'd like to suggest that you use the same bit-width for 'Dummy' as that for
'count', and initialize it to 0, so as to ensure that it won't overflow.
On Fri, Jan 28, 2011 at 1:52 PM, Slawa Olhovchenkov <slw at zxy.spb.ru> wrote:
> On Sat, Jan 29, 2011 at 07:52:11AM +1100, Bruce Evans wrote:
> > >> there are of course several possible answers, including:
> > >>
> > >> 1/ Sometimes BSD and Linux report things differently. Linux may or may
> > >> account for the lowest level interrupt tie the same as BSD
> > >
> > > But I see only 20% idle on FreeBSD and 80% idle on Linux.
> > The time must be counted somewhere, so when it is not properly accounted
> > to packet handling, and nothing much else is running, it is accounted to
> > idle.
> > To see how much CPU is actually available, run something else and see how
> > fast it runs. A simple counting loops works well on UP systems.
> #include <stdio.h>
> #include <sys/time.h>
> int Dummy;
> main(int argc, char *argv)
> long int count,i,dt;
> struct timeval st,et;
> count = atol(argv);
> gettimeofday(&st, NULL);
> for(i=count;i;i--) Dummy++;
> gettimeofday(&et, NULL);
> dt = (et.tv_sec-st.tv_sec)*1000000 + et.tv_usec-st.tv_usec;
> printf("Elapsed %d us\n",dt);
> This is ok?
> ./loop 2000000000
> 1 process: Elapsed 7554193 us
> 2 process: Elapsed 14493692 us
> netperf + 1 process: Elapsed 21403644 us
> 1 process: Elapsed 7524843 us
> 2 process: Elapsed 14995866 us
> netperf + 1 process: Elapsed 14107670 us
More information about the freebsd-performance