Array indexing vs. pointers...

mcdonald at uxe.cso.uiuc.edu mcdonald at uxe.cso.uiuc.edu
Mon Oct 10 00:31:00 AEST 1988


>In article <225800077 at uxe.cso.uiuc.edu>, mcdonald at uxe.cso.uiuc.edu gives
>six good, fairly detailed tips for optimizing C programs.  One thing to
>keep in mind here is that in general, you are wasting your time trying
>to optimize the entire program.  Most programs spend a large amount of
>their processing time in a few critical routines.

>The way to conquer this problem, and not waste a lot of valuable time
>optimizing the current program, when you could be adding features to the
>next version :-), is to profile your code.  Find out which routines the
>program spend most of it's time in, and then optimize THOSE routines.

Agreed, sometimes. Sometimes it is blatently obvious from the problem
description. Of three projects I just finished, all maybe 3000 to 5000
lines, one  does most of its work in 40 lines. One spreads out over
about 25% of the code. These were obvious from the start (pre-known
loop counts). One, my hack of Nelson Beebe's dvi driver, I couldn't
tell de novo since I didn't write it. I found a very nice profiler
called Inside! ( for the IBM-pc) on Bix. It is a crippled demo version,
but got the job done. I found that the work being done is distributed
very evenly over about 85% of the code. That means nothing can be done 
easily. Oh well!

Doug McDonald



More information about the Comp.lang.c mailing list