Dec 7, 2006

Profiling PHP with Xdebug and WINCacheGrind

Ok..so this is really short, no BS tutorial, on how to profile your PHP application under windows

Step 1
Download windows modules for your version of PHP from http://www.xdebug.org/

Step 2
Write this lines at your php.ini file


zend_extension_ts="c:/wamp/php/ext/php_xdebugXXXXXXX.dll"
; general settings
xdebug.auto_trace=0
xdebug.collect_includes=1
xdebug.collect_params=1
xdebug.collect_return=0
xdebug.default_enable=1
xdebug.extended_info=1
xdebug.show_local_vars=1
xdebug.show_mem_delta=1
xdebug.max_nesting_level=100
xdebug.trace_format=0
xdebug.trace_output_dir="c:/XXXXXXXX/"
xdebug.trace_options=0
xdebug.trace_output_name=timestamp

; debugger settings
xdebug.remote_autostart=0
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_mode=req
xdebug.remote_port=9000

; profiler settings
xdebug.profiler_append=1
xdebug.profiler_enable=1
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_dir="c:/XXXXXX/"



now, important stuff
replace XXXX's in line
zend_extension_ts="c:/wamp/php/ext/php_xdebugXXXXXXX.dll"
with name of Windows module from step 1

Also instead of c:/XXXXXX/ write path where you want to keep profiling and debug files.


Step 3
Save your php.ini and restart your web server, start your local script and cachegrind files should appear in directory from step 2

Important notice, when you debug or profile large scripts (forums, blogs, etc) profiler writes a lots of data, so be careful to have enough free space, and check constantly

Step 4
When you are done,refer to step 2 and change line
xdebug.profiler_enable=1
into:
xdebug.profiler_enable=0 , and restart Apache again.
This will stop profiling process, and every time you wish to start profiling you must change it back to 1, and restart Apache.


Step 5
Download win cachegrind from http://sourceforge.net/projects/wincachegrind/
install, and set working directory to the same direcotry as in step 2, load your files and enjoy.

Now fun part begins, you should search for functions that takes most of your execution time, and try to optimize that code...

Few general advices for fast application are:
-As less includes as possible.
-Avoid too many database connections, try to use JOINS in your SQL query to get most meaningful data.
-Avoid array sort and count inside loops.
-when ever possible use caching of database data.

14 comments:

Anonymous said...

You can also buy bundlе deаls, whiсh most гadіο
ѕtatіonѕ offer, to dеcreаѕe the οveгall
aԁ cost. Another thing you'll need is some strength to endure, because there's a good
chanсe you'll be your own producer for the show or perhaps the best producer the show has. Additionally, some new attributes make it even easier to make radio buttons do exactly what you want them to do.

Here is my website - video downloader
Also see my site: online radio

Anonymous said...

Tomb Raider, Mega Moolah, Mermaid's Millions, and Blackjack are some of the new Android game apps that have been released from Microgaming's partner,
Spin 3. Thus the games like the Mahjongg Spiele as well as
the Naegel machen games are more in demand and this is the greatest
benefit or advantage of the online games. In our next article, we'll be tackling using SNES4i - Phone to do exactly that - play those old favorites, like Chono Trigger, Super Ghouls and Ghosts, or even Super Mario Bros 3.

Feel free to visit my website :: radiosender

Anonymous said...

Tomb Raider, Mega Moolah, Mermaid's Millions, and Blackjack are some of the new Android game apps that have been released from Microgaming's partner, Spin
3. You will eventually run into the Download Location menu with two options:
Wii System Menu and SD Card. A Twitter app for Zune has been
created and is now available for download through Microsoft's Marketplace.

Here is my web page video downloader

Anonymous said...

But the the main thing is a lot of your personal data is out
there whether it's health information, bank card details or even as the Albuquerque mishap shows courtroom files. Stored energy printers. In essence, they appreciated each other and never lost sight of how lucky they felt to have each other as their spouse. In exchange you'll have to pay a bit more
for the GT 220, as most models are around $60 or $70 dollars.

Overall I'll say the game isn't that re playable. Those pain
killers and medications hide the problem without dealing with
the true cause. In 2005, the QI Group acquired a UK-based
independent telecommunications provider with a strong background in providing advanced communications solutions and technology in the United Kingdom.
That assures a steady supply since it's easily replaceable. I was excited to see what they would come up with, since I already have two children. For people from non technical background these things look like rocket science.

My blog post; click through the up coming web site

Aliya Manasa said...

Very well written blog and I always love to read blogs like these because they offer very good information to readers with very less amount of words....thanks for sharing your info with us and keep sharing.
Python Online training
python Training in Chennai
Python training in Bangalore

sathish said...

Your very own commitment to getting the message throughout came to be rather powerful and have consistently enabled employees just like me to arrive at their desired goals.
Selenium training in Chennai
Selenium training in Bangalore
Selenium training in Pune
Selenium Online training

Jaweed Khan said...

Thanks For Sharing The Information The information shared Is Very Valuable Please Keep Updating Us Time just went On reading The article Python Online Training Aws Online Training Hadoop Online Training Data Science Online Training

Softgen Infotech said...

Thank you for sharing such a nice post!

Softgen Infotech is a leading training institute for all kind of the Best Software Training in Bangalore with real-time experienced trainers with 100% Placement Assistance.

Keerthana said...

much needed Messages are Circled Through this sites,Thanks for Sharing A Post.Are you Searching For BEST PYTHON TRAINING IN CHENNAI WITH PLACEMENT???Do visit Here

python training in chennai | python training in annanagar | python training in omr | python training in porur | python training in tambaram | python training in velachery

Anu said...

The expansion of internet and intelligence in business process lead the way to huge volume of data. It is important to maintain and process these data to be efficient in data handling
devops training in chennai | devops training in anna nagar | devops training in omr | devops training in porur | devops training in tambaram | devops training in velachery

Anu said...

I have read through your blog. Its very informative and required. keep on sharing blogs and informations.

devops training in chennai | devops training in anna nagar | devops training in omr | devops training in porur | devops training in tambaram | devops training in velachery

aarthi said...

Bundle of information in a single article.It is very useful. Java training in Chennai | Certification | Online Course Training | Java training in Bangalore | Certification | Online Course Training | Java training in Hyderabad | Certification | Online Course Training | Java training in Coimbatore | Certification | Online Course Training | Java training in Online | Certification | Online Course Training

salome said...

this is interesting to read.
thank you
best-angular-training in chennai |

Lookobeauty said...

I want people to know just how good this information is in your article. It’s interesting content and Great work.