Re: The strange speed of a program!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for your advice. Someone on gnu.gcc.help gives a very interesting
result of my program. Quoted from his mail:

gcc 3.3.4 (Slackware)
gcc -O3 -static

The same binary was run on 4 different processors, my results are:
./a.out 50 1024 [01]

              init:            0             1
Pentium MMX (200MHz)       10.860000     37.870000
Pentium II (400MHz)         1.330000      7.090000
mobile Athlon XP (1400MHz)  6.950000      4.060000
Pentium4 (2.80GHz)          9.290000      0.710000 

Also, It seems that the overflow of random data without initialization
slow down the speed. But I am not sure now.

In your mail:
>From: jlh <jlh@xxxxxx>
>Reply-To: 
>To: bear <xiongguanglei@xxxxxxxxxxxxxxx>
>Subject: Re: The strange speed of a program!
>Date:Wed, 08 Jun 2005 15:26:41 +0200
>
>
> > I have a program whose speed is so strange to me. It is maily used
> 
> Same here (compiled with -O2):
> 
> ./a.out 50 1024 0   ->   CPU time: 6.510000 sec
> ./a.out 50 1024 1   ->   CPU time: 3.880000 sec
> 
> but with different arguments:
> 
> ./a.out 1000 128 0  ->   CPU time: 0.270000 sec
> ./a.out 1000 128 1  ->   CPU time: 2.960000 sec
> 
> This is also very interesting: If you copy the initializing
> for-loop once *before* starting the timer, you can't reproduce
> the odd effect anymore.
> 
> ./a.out 50 1024 0   ->   CPU time: 2.210000 sec
> ./a.out 50 1024 1   ->   CPU time: 4.040000 sec
> 
> and
> 
> ./a.out 1000 128 0  ->   CPU time: 0.710000 sec
> ./a.out 1000 128 1  ->   CPU time: 2.990000 sec
> 
> Someone more knowledgable than me will explain it using the
> right terms.  I can only say that it has something to do with
> how the kernel (linux here) manages memory.  I once found out
> that memory physically gets allocated only at its first use,
> not during the malloc(), i.e. very large chunks can be allocated
> without causing any swapping.  The swapping only starts to take
> place when you use that memory for the first time.  Maybe in
> above case the kernel 'knows' that the memory pages are being
> read without ever having been initialized and doesn't bother
> loading anything... just speculation.
> 
> jlh
>



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux