[Ilugc] How to improve the throughput of c/c++ code

  • From: steve@xxxxxxxxxxxx (steve)
  • Date: Thu Sep 30 16:51:37 2010

Hi,

On 09/29/2010 08:52 PM, narendra babu wrote:

Hello all ,

I have done some search to improve the performance of existing c/c++ code , 
but could not find much .

So it will be great if any body can share thoughts on how to improve the 
performace or throughput of code .


This question is too generic to answer sensibly. Consider the following points:

a. Is your application I/O bound or CPU bound (ie: does it do mostly I/O or is 
it CPU intensive ?)
b. What do you define as 'performance' ? Low memory consumption ? Low 
latency/high user responsiveness ? Fast processing ?
c. What is the environment in which your application executes ? (ie: what are 
the external dependencies of the application's input and output ?)

The first step to 'improving the performance' is 'understanding the 
performance' 
of your application. So, I would recommend running your application under a 
profiler (there are tons of them out there both generic and specialized tools).

also if anybody has worked in converting single threaded code to 
multithreaded code in c/c++ .


Don't do this without first understanding why one would need to do this and 
even 
then don't do it without evaluating what other options are available. I say 
this 
because, writing multi-threaded code more often than not is too much effort to 
solve the wrong problem :-). That is to say, if you are converting single 
threaded code to multi-threaded /only/ for the sake of perceived gain in 
performance then don't do it.

do we any tools to identify where we can improve perfromace of c/c++ code .


strace/ltrace (especially the -C option), gprof, oprofile ...and simple printf, 
if used sensibly.

cheers,
- steve

-- 
random spiel: http://lonetwin.net/
what i'm stumbling into: http://lonetwin.stumbleupon.com/

Other related posts: