Welcome Guest, Not a member yet? Register   Sign In
Nice Code Tipp is needed or how to minimize memory usage
#3

[eluser]jedd[/eluser]
Quote:b) memory usage of 3MB-6Mb...

Memory usage will be Fun. Have you looked at the [url="http://ellislab.com/codeigniter/user-guide/general/profiling.html"]Profiling Class[/url]? That'll give you some amount of insight, but possibly not detailed enough for your purposes.

In general terms, you can look at destroying objects and data once you've finished with them (rather than waiting for PHP to clean them up on exit). You can minimise the amount of data you pull from databases (most people seem to get more than they need, and let PHP cherry pick what they actually require). You can look at a separate database - not OLAP but in the same spirit, especially if this data can be 24 hours stale, for example, you may be able to dump a smaller database that contains only the data you want and/or in a more efficient format for what you're doing.

You are likely to do lots of comparisons of different approaches to see which is faster for your particular data and algorithms.


Quote:Usually I call database directly from controller , then parsing data , generate HTML in controller, and pass it to views

Staring into my crystal ball, I can see problems in your future.

If your database calls are in your controller, then every time you come up with an optimisation for a section of code, you have to replicate that to all your controllers that happen to use that (or similar) code. This could, by the sounds of it, be multiple methods within multiple controllers.

So, to come back to your original question, you could put database calls into models - it'll make it faster to make it faster, if you see what I mean.

Generating HTML in controllers will suffer the exact same type of problem, of course, though probably not to the same degree.

Or you can just buy a faster computer.


Messages In This Thread
Nice Code Tipp is needed or how to minimize memory usage - by El Forum - 03-17-2009, 11:49 AM



Theme © iAndrew 2016 - Forum software by © MyBB