views:

54

answers:

1

hello everybody.

Does anyone know if OO and php classes are more resource consuming than normal functions that have the same result.

And is there a simple php script that can give me exact RAM and CPU consumption by any given script so that I can monitor and limit resources usage, to code better for shared hosting.

Thank You.

+3  A: 

Whether they differ in resource consumption is unimportant. You do not pick one over the other for matters of performance but for the paradigm.

For benchmarking and profiling, you can use XDebug and memory_get_usage and memory_get_peak_usage. You might also be interested in ab and similar tools.

Gordon
I think that the resource consumption is unimportant for low traffic websites or applications, but what about very height traffic ones?
mohamed87
@mohamed87 you dont scale websites by picking a certain paradigm in a language. Scale out horizontally, add more hardware, farm out dedicated servers, load balancers, use a compiled language, etc.
Gordon
thanks a lot Gordon!
mohamed87
@mohamed87: If the traffic of a site is that intense, the use of a scripting language like PHP will become the more significant bottleneck long before using OOP vs procedural will be. RAM is much cheaper than the man months of hair pulling it can take to maintain a large procedural codebase.
webbiedave
@mohamed87 you are welcome
Gordon
webbiedave, I don't understand well but are you saying that php is not worth using for very high traffic sites? or am I wrong?!
mohamed87