[Gloucs] How much faster is assembly language
Bob Wilkinson
rwilkinson at messagelabs.com
Tue Sep 20 17:21:20 UTC 2011
On Mon, Sep 19, 2011 at 06:33:31PM +0100, Gerd Busker wrote:
> Bob Wilkinson wrote:
> >I extended the search space out by a further digit so we test
> >numbers between 10 and 100000 (rather than 10000 as previously) and
> >see...
> Excellent, now you can at least see the startup split from the actual code.
> Can you now add at least -O3 to the C optimizer?
>
> Gerd.
bob at poland:~/src/problems_for_computer_solution/07_armstrong_numbers$ make armstrong_big_macro
/usr/bin/gcc armstrong_big_macro.s armstrong_big_main.s power.s -o armstrong_big_macro
bob at poland:~/src/problems_for_computer_solution/07_armstrong_numbers$ time ./armstrong_big_macro
<cut>
armstrong number of 92727 is 92727
armstrong number of 93084 is 93084
real 0m0.044s
user 0m0.050s
sys 0m0.000s
bob at poland:~/src/problems_for_computer_solution/07_armstrong_numbers$ make armstrong_big_string
/usr/bin/gcc -O3 -o armstrong_big_string armstrong_big_string.c -lm
bob at poland:~/src/problems_for_computer_solution/07_armstrong_numbers$ time ./armstrong_big_string
<cut>
ARMSTRONG NUMBER is 92727
ARMSTRONG NUMBER is 93084
real 0m3.278s
user 0m3.280s
sys 0m0.000s
bob at poland:~/src/problems_for_computer_solution/07_armstrong_numbers$ rm armstrong_big_string && make armstrong_big_string
/usr/bin/gcc -O4 -o armstrong_big_string armstrong_big_string.c -lm
bob at poland:~/src/problems_for_computer_solution/07_armstrong_numbers$ time ./armstrong_big_string
<cut>
ARMSTRONG NUMBER is 54748
ARMSTRONG NUMBER is 92727
ARMSTRONG NUMBER is 93084
real 0m3.277s
user 0m3.280s
sys 0m0.000s
bob at poland:~/src/problems_for_computer_solution/07_armstrong_numbers$
So switching on heavy optimisation flags slows it down. Maybe it
just happens that I stumbled upon a particular problem that caused
the compiler to generate inefficient code, howwver, the source code
does not seem particularly obscure.
Bob
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
More information about the gloucs
mailing list