www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/03/03:58:31

Date: Sun, 3 Jan 1999 10:55:54 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: "Mikko V.I. Parviainen" <mvparvia AT delta DOT hut DOT fi>
cc: djgpp AT delorie DOT com
Subject: Re: Allegro, pointers : how do I get line from BITMAP?
In-Reply-To: <mvparvia.915186926@snakemail.hut.fi>
Message-ID: <Pine.SUN.3.91.990103105517.12860G-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

On 1 Jan 1999, Mikko V.I. Parviainen wrote:

>   b->line[y][x]
> 
> Functions well. However, the eight indirections (?) of b
> for every cell do add significant overhead

How do you know this kind of code ``adds a significant overhead''?
Did you measure your program with a profiler?  Did the profile thus
produced show that this code is a bottleneck?  (A function is a
bottleneck if it takes 30% or more of the run time.)

If not, chances are you are optimizing in the wrong place.  For
example, if this code takes only 10% of the run time, speeding it up 4
times will only slash the overall running time by 8%, which is not
much.

> In other words, I am trying to define a variable so that
> I could say
>  
>   temp[y][x]     to access      b->line[y][x]
> 
> but cannot find the right expression for temp.

Leave these optimizations to the compiler, that's what it's for.
Chances are, it is already doing that for you (look at the assembly it
produces if you want to know).

Again, unless the function where this code lives takes up a
significant portion of the run time, don't waste your time optimizing
it.  Use the profiler to guide you to places which really are in the
need of optimization.  It is a well-known phenomenon that guessing
where the hot spots are will almost never yield the right place.

The DJGPP FAQ explains in chapter 13 how to use the profiler.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019