Q:

O flag to use?

1
Like
Answer
Comment
Flag
Tags:
Thanks for your feedback!
A:

1 Answer

rank
1
1
Like
Comment
Flag
There's a common misconception that larger numbers behind the -O option might automatically cause 'better' optimization. First, there's no universal definition for 'better', with optimization often being a speed vs. code size tradeoff. See the detailed discussion for which option affects which part of the code generation. A test case was run on an ATmega128 to judge the effect of compiling the library itself using different optimization levels. The following table lists the results. The test case consisted of around 2 KB of strings to sort. Test #1 used qsort() using the standard library strcmp(), test #2 used a function that sorted the strings by their size (thus had two calls to strlen() per invocation). When comparing the resulting code size, it should be noted that a floating point version of fvprintf() was linked into the binary (in order to print out the time elapsed) which is entirely not affected by the different optimization levels, and added about 2.5 KB to the code. ...  more
linux.die.net

Related Videos

Add your answer...

Top Answerers

1.
vanity fair
7 Answers in the past week
2.
Robert Turner
4 Answers in the past week
3.
jacob kind
3 Answers in the past week

Top Askers

1.
Deitty smith
3 Questions in the past week
2.
Frank Bell
2 Questions in the past week
3.
Charles McAtee
2 Questions in the past week

Top Supporters

1.
Tom Wagner
9 Likes given in the past week
2.
Nancy Hayden
2 Likes given in the past week
3.
Rachel Kellen Gill
3 Likes given in the past week
...