PHP function server load graph?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

PHP function server load graph?

Post by JAB Creations »

I was wondering if anyone has attempted to create a visual graph displaying relative amounts of load in typical scenarios per function? Having such a graph would be beneficial by giving a visual contrast between the load/weight of two functions that could be used to achieve the same goal. For example if using function a more then three times outweighs a single instance of using function b that one instance would benefit both the application and the programmer in the long run both in efficiency and better coding practices respectively. If such a graph does not exist I think it'd be beneficial if we as a community could come together work on a PHP benchmark to help create such a graph.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: PHP function server load graph?

Post by onion2k »

Server load is a pretty rubbish way of benchmarking your scripts. All it'd tell you is that the script makes the server do some work ... well duh! You'd be better off using a proper profiling tool like xdebug.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: PHP function server load graph?

Post by JAB Creations »

I don't want to sound fresh but you don't seem to comprehend why people do benchmarks. Using function A a thousand times and then function B a thousand times will help clarify overall what functions to concentrate on learning first out of the whole mixed bag. If I engineered a video card I may want to see how the same card with more or less ROPs would perform in regards to various 3D rendering techniques. The same thing with the number of shaders or vertex processors. Sure I may not have built any video cards or created PHP...but it would give much more insight then to just blindly read through things...plus it's a little more hands on. :D
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: PHP function server load graph?

Post by onion2k »

I understand perfectly why people do benchmarks. What you don't understand is how people do benchmarks. If you use the server load all you'll know is how much work the server was doing at the time the script ran. That sounds like what you want, but it isn't. The server is doing a lot more than just running your script. What if there's a spike in the CPU load from sendmail, or apache, or ftpd, or any of the other hundreds of things the server is running at the same time as your benchmark? What if your script makes one of the many daemons act up? There are too many external factors to make the server load a useful figure.

By using a proper profiling tool like xdebug you can measure what your script was using and only what your script was using. If something else on the server happens to have an increased workload at the time your script runs you'll know that it wasn't your script that was the problem. Furthermore, you'll be able to add profiling points to the script so you'll know which part of the script took up the most resources. Try doing that with the server load averages.
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: PHP function server load graph?

Post by ghurtado »

Xdebug is probably exactly what you want. I think it used to power the profiling feature of the Zend Development Environment, and I have never seen better profiling (graphs included, time per function, number of times methods were called, etc...) in any other IDE.

http://www.onlamp.com/onlamp/2008/03/11 ... ofiler.jpg

Is there a way to get similar features with xdebug / PDT / Eclipse?

If not, that would be a killer Eclipse plugin.
Post Reply