Solved

G++ Compiler -O (Optimization) Tag

Posted on 1998-12-29
3
2,139 Views
Last Modified: 2012-05-12
What's the benefeits of using this tag?

I'm compiling a MUD engine, right now using g++ -c, and am wondering if there's any benefeit (and if, then what specifically) -O optimization will give me, in terms of space, memory, speed, etc. And if I should use it.

Thanks!

Matt-
matt@anji.smhall.org
 
0
Comment
Question by:tribal9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Accepted Solution

by:
sosedada earned 0 total points
ID: 1181272
-O is equivalent to -O1, or the first optimization level.  g++ also has -O2, -O3, and -Os.  The downside of these is compilation time.  However, they will speed up your program, definitely.  I believe in most cases executable size is decreased, but this is not guaranteed.

-O1, -O2, -O3 perform increasing amounts of optimization, require increasing amounts of time and also have a higher chance of breaking.  Optimization usually only breaks if your code is really complex.  

-Os is an options that performs no optimizations that increase executable size.  This means less speed optimization but a greater decrease in size.

As far as memory usage goes, optimization should decrease it.  Variables may be eliminated and optimization should decrease the number of lines of code necessary.

I would recommend using -O1 (or -O) for sure.  Perhaps before distribution, you could play with the higher optimization options to see how they would benefit you.
0
 
LVL 86

Expert Comment

by:jkr
ID: 1181273
sosedada - wow, great elaboration! (indeed  - hard to improve...  ;-)
0
 

Author Comment

by:tribal9
ID: 1181274
By far the best answer I have recieved on here in awhile.

You earned your 5 points. =)


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to split this in C++ 4 129
Least Squares Curve Fitting 4 133
Path to  STL Map header file 1 91
Error C2678: binary '!=': no operator found... 4 73
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question