in reply to Foreach Loop Optimization
How much of that 9 seconds is perl runtime, and how much is the time the web browser takes to render the table? Or is that just the perl time? Rendering an 800 row table usually slows browsers down a bit...
There's nothing obviously slow about the way you're doing things.
I suggest doing some experimenting.
What's the speed if you comment out the print statements?
Is FormatTime doing anything stupidly slow?
That's all I can think of offhand...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Foreach Loop Optimization
by upallnight (Sexton) on Aug 01, 2007 at 15:45 UTC | |
I haven't had time to read them all but I found what was slowing it down so much: the print command on its way to the browser Here is the FormatTime function code:
At first I had shrunk that function down to almost nothing and then thought of the print command. Instead of printing inside the loop, I repeatedly appended the output to a string $output and then printed that string outside the loop:
This changed the run time from an average of 10 seconds to 3 seconds! To get the run time I don't do anything fancy, just print the time at the beginning and end of the script. Thanks for all the replies! | [reply] [d/l] [select] |
by McDarren (Abbot) on Aug 04, 2007 at 03:52 UTC | |
.... is pretty darned ugly (no offense intended). You could tidy that up somewhat, and make it a bit more readable, by doing something like: Notes:
Hope this helps, | [reply] [d/l] [select] |
by upallnight (Sexton) on Aug 06, 2007 at 14:02 UTC | |
I still am looking at the html output to see if I can speed up the browser rendering. I took out the javascript and input form fields, but its still taking as long to load the page. It must be the table with 750 rows of data thats bogging the browser down. | [reply] |