Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

O flag to use?

FLAG
0
10 Posted

O flag to use?

0

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. Optimiza

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.