# Performance/memory problems with arrays?

#### Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on
: 7bit

I am working on some financial calculators and although I succeeded to
created the required formulas I am not sure about the following.To give an
example: when somebody puts a capital on the bank with a yearly interest of
x %  , the final capital after, say, 30 years can easily be calculated.
Since I want to be able to show the capital created after every year I
prefer to do it with a loop, something like
for(\$x= 1; \$x < 30; \$x++){
\$capital = \$capital*(1 + \$interest /100)
} .
Another reason for such a loop is that the visitor could tell that he want
to withdraw some capital in the so-manieth year
Now let's say the visitor of the page can do a "quick scan" (just showing
the final amount)  and request a table with all the yearly amounts
afterwards. In this case I will either have to store all the yearly capital
values into a an array and register that array to a session, or I will need
to do the whole loop again but this time something like
\$capital = \$capital*(1+ \$interest/100);
echo "<tr><td>\$capital</td></tr>";
Although the formulas I "translated" from several excel sheets work fine, I
would like to know if storing such arrays could have negative consequences
for performance or memory on the server
Alternative suggestions, of course are also welcome. I tried to find similar
scripts on Google but I wasn't very successfull, probably because I am not
very familiar with the English financial terms

Thanks for any help.

Martien.

## Re: Performance/memory problems with arrays?

Martien van Wanrooij wrote:

Martien,

memory and cpu utilization.

Would storing arrays have negative consequences?  Sure.  But so would
calculating the figures every time.

Which is better?  It's impossible to tell.  It all depends on your
server, your users (both number and frequency) and probably a dozen
other things.

You need to figure out how much data you're talking about and how often
it's being requested.  That will help you determine which is the better
way to go.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

## Re: Performance/memory problems with arrays?

Thanks Jerry, the problem is that I am not very "handy"  at estimating such
performance issues, maybe it is just a matter of experience. Not that I am
extremely  worried that my mortgage calculation will be visited at the same
time by so many visitors that it would make crash my hosting provider's
server but I want to take in mind such considerations from the very
beginning. Anyway your reaction makes me think that I shouldn't be too
worried about the script I am writing, thanks agein :)