Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How demanding is my PHP script?
Old 09-28-2007, 03:33 PM How demanding is my PHP script?
skyblue's Avatar
Super Talker

Posts: 101
Trades: 0
Can someone explain to me, how could i know how much server resources is required to execute some php script, i mean how demanding is that script? Without that i'm never sure which way of coding is better than any other. Is there any site where i can test it or some kind of software?

Thanks,
Milan
skyblue is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-28-2007, 04:36 PM Re: How demanding is my PHP script?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Not really... At least, not that easily...

What you are looking to is a profiler. PHP have a really good one existing.
Xdebug:
http://www.xdebug.org
The thing is that Xdebug must be installed on the server, as it's an extension of PHP, and if you use a shared server, you won't be able to install it.

But, couple it with wincachegrind ( windows: http://sourceforge.net/projects/wincachegrind) or Kcachegrind (linux: http://kcachegrind.sourceforge.net/cgi-bin/show.cgi ), and it will show you how much time is spend in which functions, and how many time those functions where called.



But what it shows you, is which share of the total run time was needed for a specific function, not how many pressure was put on the server.
For that, there is only 1 way as I know of: a load test.
Pratically, you send bots to your site, that will makes a lot of requests to emulate several user browsing your site at the same time, and you keep a server resources monitoring opened, to see how many requests/seconds uses how many resources.

This is especially true with services like apache, who are threaded, and for which you cannot know before you run which one correspond to each process.
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 09-28-2007 at 04:39 PM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-28-2007, 05:24 PM Re: How demanding is my PHP script?
skyblue's Avatar
Super Talker

Posts: 101
Trades: 0
Thank you very much for long reply. I don't have dedicated server so i can't use first solution, but i think i'll have more luck with load test. I found some microsoft program called "Web Application Stress Tool", so i'll try it. At least , i know where to search for answer. Thanks again.
skyblue is offline
Reply With Quote
View Public Profile
 
Old 09-28-2007, 05:47 PM Re: How demanding is my PHP script?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
You're welcome.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-28-2007, 05:57 PM Re: How demanding is my PHP script?
Skilled Talker

Posts: 60
Name: Nick Martin
Trades: 0
The profiler will help you know how much of a resource hog your code is. Because PHP is inherently a database scripting language you will want to focus on any queries that are being run as well. Indexing large tables that are queried often can greatly improve performance.


Sorry if I am pointing out the obvious...
SpudNik is offline
Reply With Quote
View Public Profile
 
Old 09-28-2007, 06:37 PM Re: How demanding is my PHP script?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Totally true...
In every script I've profiled, sql queries took between 40 and 60 % of the total run time.

This is where most of the optimizations should be done, and first targeted.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 10-01-2007, 01:55 AM Re: How demanding is my PHP script?
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Usually a script not using any external resources like database or remote server will not consume much resources, unless it does image resizing or complicated math calculations. Most bottlenecks come from database usage and this should be optimized first of all.

One of the most common pitfalls in database administration is lack or inproper usage of indexes, while proper one can increase the performance of certain DB query up to twenty times - from 1 second to 0.05 second on highly loaded server.

If you use database with your scripts devote more time to database optimization, don't bother about the script itself.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to How demanding is my PHP script?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24939 seconds with 12 queries