Page 1 of 1

Performance Bottlenecks

Posted: Sun May 23, 2010 1:31 am
by JakeJ
I have a script that takes a LONG TIME to execute fully.

How can I find out how long different parts of it are taking to run?

I have a lot of database queries, I have a bunch of include files that are generating graphs and the final output of it all is a PDF file.

I've got some serious bottlenecks going on here and I need to figure out where it's getting hung up. It wasn't behaving like this before. Average execution time was only about 20 seconds.

I might have an infinite loop in there somewhere of course but I'm not sure since it ends up stopping at a slightly different line number each time and those particular lines don't involve any query initiation OR looping behavior.
**Edit.. whether I set the execution time to 30 seconds or 600, it times out in the same area but not on any line that gives me any clue as to the bottleneck.**

Any help tracking this down is appreciated.

Re: Performance Bottlenecks

Posted: Sun May 23, 2010 4:59 am
by Eran
This is called profiling, you should google it.
At the most basic level, time each part using microtime(). You could write the results to a file if it times out without giving you output