473,788 Members | 3,078 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Performance/memory problems with arrays?

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>$capit al</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.

Feb 9 '07 #1
2 1469
Martien van Wanrooij wrote:
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>$capit al</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.
Martien,

Programming is all about tradeoffs. Often time the tradeoff is between
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.
js*******@attgl obal.net
=============== ===
Feb 10 '07 #2

"Jerry Stuckle" <js*******@attg lobal.netschree f in bericht
news:Eb******** *************** *******@comcast .com...
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.
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 :)

Feb 10 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5595
by: Rodd Snook | last post by:
I have an application which makes extensive use of the Scripting.Dictionary object. I'm not doing anything silly like putting them outside the page scope -- just creating quite a few of them and stuffing quite a lot of data (from and MS SQL database) into them. On Windows 2000 server, everything is fine. If the data structures get really big it slows down, but for normal operation it's no problem. Recently our hosting provider moved to...
4
3363
by: Martin | last post by:
I am using graphics as backgrounds for forms,buttons,labels etc. The question is: is it faster to load all graphics from files on app start or to use it embeded (places in editor during design). Reason for my question is that application has 5mb, while without graphics it has cca 400kb. Graphic files (bmps) take about 200kb (in program, they are repeated many times, ie almost all labels (around 200) have same background image)). Also,...
19
3155
by: Tom Jastrzebski | last post by:
Hello, I was just testing VB.Net on Framework.Net 2.0 performance when I run into the this problem. This trivial code attached below executed hundreds, if not thousand times faster in VB 6.0 than in .Net environment, under VS 2005 Beta 2. Does anyone have any idea whether this will be addressed in the final release? Thanks, Tomasz
5
4657
by: Alan Howard | last post by:
We're getting "ERROR (0x8007000E) Not enough storage is available to complete this operation" errors on a fairly large, busy ASP/SQL Server web site. The error is being thrown on a line calling oRs.GetRows() on one of our busiest pages. The array returned from the GetRows() call will be 'cleaned up' when the page goes out of scope, but I wonder if we should be calling Erase specifically after the last usage to explicitly free allocated...
37
3817
by: jortizclaver | last post by:
Hi, I'm about to develop a new framework for my corporative applications and my first decision point is what kind of strings to use: std::string or classical C char*. Performance in my system is quite importante - it's not a realtime system, but almost - and I concern about std::string performance in terms of speed. No doubt to use std implementation is a lot easier but I can't sacrifice speed.
22
3247
by: roadrunner | last post by:
Hi, Our website has recently been experiencing some problems under load. We have pinpointed a particular function which slows dramatically when we have these problems. Normally it should execute in under a second but it rises to about one minute under duress. The code is fairly straight forward with no calls to databases or any other servers. The only dubious thing I can see is that it retrieves several arrays from the Application...
4
5532
by: Gregory.A.Book | last post by:
I'm working with displaying and manipulating very large image sets. The program handles anything from 2D images to 4D RGB volumes in a time-series. I've been using dynamically allocated arrays to accomplish this, but having recently added the ability to load and display 4D data, I've run into some significant performance issues. For a dataset of size 256x176x176x1, it takes about 30 seconds to allocate the array. Loading the data into...
7
2576
by: Michael D. Ober | last post by:
When calling Enqueue, the internal array may need to be reallocated. My question is by how much? In the old MFC array classes, you could tell MFC how many additional elements to add to the array when it needed to reallocate, which greatly boosted performance relative to adding 1 element at a time. Thanks, Mike Ober.
13
4607
by: atlaste | last post by:
Hi, I'm currently developing an application that uses a lot of computational power, disk access and memory caching (to be more exact: an information retrieval platform). In these kind of applications the last thing that remains is bare performance tuning. So for example, you can do an 'if then else' on a bit like a 'case/ switch', an 'if/then/else' and as a multiplication with a static buffer. Or, you can do sorting with an inline...
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.