Mail Archives: djgpp/1997/08/29/05:18:37
Orlando Andico <orly AT gibson DOT eee DOT upd DOT edu DOT ph> wrote:
>On Thu, 28 Aug 1997, Michael L. Smith wrote:
>
>.
>> C Version:
>>
>> int i;
>> int x;
>>
>> main()
>> {
>> for(i=1; i<1000000000; i++) x=i;
>> }
>>
>> Basic Version: (identical version used for both OmniBasic and Power
>> Basic)
>>
>> dim i as long
>> dim x as long
>>
>> for i=1 to 1000000000
>> x=i
>> next i
>
>That's meaningless as a benchmark, it's just a do-nothing loop. Since
>OmniBasic outputs C code that GCC compiles, it can't be faster than GCC,
>even if it's a compiler in its own right. Try this for the C version, and
>see if OmniBasic is still faster:
>
>register int i;
>int x;
>main()
>{
> for (i = 1; i < 1000000000; i++) x = i;
>}
>
>and compile it with gcc -O3 -fomit-frame-pointer
>
>I'm pretty sure that OmniBasic gets its marginally faster times on this
>"benchmark" with the judicious use of register variables and compiler
>optimizations.
>
>Besides, using the above "benchmark" is pretty worthless. I think a better
>test of each compiler would be to calculate the Fast Fourier Transform of
>a very large 2D array. Functions to do this are available in both Basic
>and C, and at least it's a "real world" application.
>
>
>-------------------------------------------------------------------
>Orlando Alcantara Andico
>WWW: http://www2.mozcom.com/~orly/ Email: orly AT mozcom DOT com
>ICBM: 14 30 00 N 120 59 00 E POTS: (+632) 932-2385
>
With the -O3 optimization turned on, it really is a "do nothing loop".
GCC will detect that the result stored in x is never used and thus
will never calculate it. Since that is the only instruction in the
loop, it willremove the loop. The program should run instaneously.
-Shane
- Raw text -