Performance Bottlenecks

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Performance Bottlenecks

Post 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.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Performance Bottlenecks

Post 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
Post Reply