User forums > General (but related to Code::Blocks)
[OT] - Interesting optimization papers
mandrav:
Here's a site I stumbled upon the other day with a few interesting papers regarding C++ code optimization.
http://www.agner.org/optimize/
Game_Ender:
That is very good site. One of the parts I don't like is where basically says to use C++ like its C with classes, ie: No run time type information or exception handling.
Good to see you back mandrav, I hope whatever caused your absence went very well (never did learn why you were away).
mandrav:
--- Quote from: Game_Ender on July 31, 2006, 02:30:35 pm ---Good to see you back mandrav, I hope whatever caused your absence went very well (never did learn why you were away).
--- End quote ---
Hum, I was on vacations :oops: . Thanks anyway :)
sethjackson:
--- Quote from: mandrav on July 31, 2006, 02:40:41 pm ---
--- Quote from: Game_Ender on July 31, 2006, 02:30:35 pm ---Good to see you back mandrav, I hope whatever caused your absence went very well (never did learn why you were away).
--- End quote ---
Hum, I was on vacations :oops: . Thanks anyway :)
--- End quote ---
Now everyone has to get back to work. :lol:
Nice to see you back. :D
thomas:
--- Quote from: Game_Ender on July 31, 2006, 02:30:35 pm ---One of the parts I don't like is where basically says to use C++ like its C with classes, ie: No run time type information or exception handling.
--- End quote ---
From the strict viewpoint of optimisation, he is right, though. It is no secret that both of these consume considerable CPU time. I am not denying the useful applications and advantages of exceptions, but they are not free.
I don't have figures at hand for RTTI, but I have timed the overhead caused by enabling exceptions with gcc 3.4 some months ago. Simply turning on exceptions (without actually throwing anything) makes your code about 6-8% slower.
The time for throwing and catching an exception (which luckily does not happen in "normal" operation) is unpredictable, it could take milliseconds in the worst case. In the "normal" case, you can assume it is something on the order of 100 to 1000 times more expensive than a conditional branch (depends on how much stack has to be unwound and on what happens in destructors).
Thus, from the strict viewpoint of optimisation, it is not entirely unreasonable discourage exceptions where they are not absolutely necessary.
Navigation
[0] Message Index
[#] Next page
Go to full version