On Tue, May 22, 2012 at 2:54 PM, rene7705 <rene7705@xxxxxxxxx> wrote: > On Tue, May 22, 2012 at 12:32 PM, rene7705 <rene7705@xxxxxxxxx> wrote: >> On Tue, May 22, 2012 at 2:32 AM, tamouse mailing lists >> <tamouse.lists@xxxxxxxxx> wrote: >>> On Mon, May 21, 2012 at 7:31 AM, rene7705 <rene7705@xxxxxxxxx> wrote: >>>> On Mon, May 21, 2012 at 1:17 PM, Simon Schick >>>> <simonsimcity@xxxxxxxxxxxxxx> wrote: >>>>> Specially the function rajmvServiceLog_graphs_raphael_calculateData() with a >>>>> code of ca. 280 lines is quite long ... >>>> >>>> 280 lines is long?! :) >>> >>> In general, yes. 280 lines is long. Too long, likely. Usually it >>> indicates you aren't designing your code in a top-down fashion, and it >>> is a high candidate for refactoring in order to break out into >>> reusable functions. A rule of thumb is no more than 50 lines per >>> function, most much less. Back in the day when we didn't have nifty >>> gui screens and an 24 line terminals (yay green on black!), if a >>> function exceeded one printed page, it was deemed too long and marked >>> for refactoring. >> >> Well, I split up that long function into several new functions (using >> pass-by-reference) this morning.. >> Problem is, now it won't work anymore due to memory consumption errors! :( >> >> I'd love to know what I'm doing wrong here. >> >> Demo at http://skatescene.biz/sites/mediabeez.ws/stats >> Code is attached to this mail. > > hmm, this might actually be an issue with my dev webserver... it's > taking 400mb of memory and over 10 minutes to process just 3500 > records. > My live hosting does 2200 records in 64M of memory and significantly less time.. > > I'll keep digging. Seems to be the writing of the html+json data to a file that's causing the delay on my dev server. Doing the totals calculation on my dev server for 3500 records takes about 2.5 seconds, with the old code. Will soon see how long it takes with the refactored code of today. Anyone got a clue about why a few ten thousand calls to fwrite() will slow down a wampserver so much?... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php