> [log in to unmask] said:
> > I appreciated that you were just supplying representative code.
> > However if it is possible to avoid dynamic allocation, then you
> > generally get better performance. Of course, if you want the
> > convenience, it comes at a price at run time (as with most things in
> > life!).
>
> Personally, I have a hard time to understand why dynamic allocation
> of a large module variable would have any noticeable performance
> difference as to a variable statically allocated in a module or a
> common block in any respect besides the time it takes to allocate and
> deallocate the variable.
I can think of two reasons for minor performance penalties. First, with
a statically allocated variable, one has a static address, or at worst a
static offset into a region if the compiler implements the facility to
make nonsaved module variables disappear when no procedure is accessing
the module. With an allocatable variable, one at least needs additionally
to load the address of the allocated variable into an index register, or
use indirect addressing if the hardware supports it. This adds at least
one extra memory cycle, and maybe more.
Second, one needs to compensate for the possibility that the lower bound
might not be zero. With a statically allocated variable, the compiler can
subtract the static lower bound from the static address before it creates
instructions that reference the variable. With a dynamically allocated
array, which includes a dynamic lower bound, this subtract has to be done
at run time.
--
Van Snyder | What fraction of Americans believe
[log in to unmask] | Wrestling is real and NASA is fake?
Any alleged opinions are my own and have not been approved or disapproved
by JPL, CalTech, NASA, Sean O'Keefe, George Bush, the Pope, or anybody else.
|