best methods to do C,C++ code optimization ?

S

swathi

What are the best methods to do C,C++ code optimization manually ?
I has gone though some links sill not satisfied.
Can any one send me best optimization links
 
V

Victor Bazarov

swathi said:
What are the best methods to do C,C++ code optimization manually ?
I has gone though some links sill not satisfied.
Can any one send me best optimization links

Try "Efficient C++" book. The main thing to understand is that any
optimizations should be based on measuring and analyzing.

V
 
A

Andre Kostur

What are the best methods to do C,C++ code optimization manually ?
I has gone though some links sill not satisfied.
Can any one send me best optimization links

Measure, measure, measure. Use some sort of profiling tool to find out
where your code is _actually_ too slow. Then look at why that code would
be too slow and fix it. Usually by changing algorithms.
 
V

Victor Bazarov

Andre said:
Measure, measure, measure. Use some sort of profiling tool to find
out where your code is _actually_ too slow. Then look at why that
code would be too slow and fix it. Usually by changing algorithms.

The usual spiel about what to do after you measure, is "prevent extra
work from being performed" and "cache everything you can" and "use
lookup tables everywhere". When none of those are possible (i.e. they
have all been already applied), rearrange your objects in memory to
reduce CPU cache misses and page faults. Oh, and one more is "do all
work when the user is not looking", i.e. in the "background". Good
luck!

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top