• Like

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Debugging and Profiling PHP

  • 3,449 views
Uploaded on

My talk on debugging and profiling PHP from the OSDC 2010 conference in Melbourne, 2010.

My talk on debugging and profiling PHP from the OSDC 2010 conference in Melbourne, 2010.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
3,449
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
46
Comments
0
Likes
5

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Transcript

  • 1. DEBUGGING AND PROFILING PHP Graham Weldon
  • 2. WHOM? Graham Weldonhttp://grahamweldon.com @predominant PHP, 10 years Zend Certified Engineer CakePHP core team http://cakephp.orgHumble slave for CakeDC http://cakedc.com
  • 3. DEBUGGING PROFILING Making stuff work Making stuff fast
  • 4. DEBUGGING Making stuff work
  • 5. WHY?• Bugs are bad.. Mmmkay.• Locate issues during runtime of PHP• Inspect data realtime during request• Normally lasts only a few milliseconds• Speed up issue resolution
  • 6. HOW?• Debugging module for PHP• Execution control• Breakpoints• Watch Variables• Source code
  • 7. PHPWORKFLOW PHP Execute Exit
  • 8. DEBUGGING WORKFLOW PHP Debugger Execute User ControlBreakpoint Exit
  • 9. ENTER XDEBUG• Enables debugging in PHP • Enhances normal error reporting• Provides all the access debuggers need to control • Provides protection against PHP runtime common issues (recursion)• View variables at runtime • Open source• Gain insight into code state • Free (no.. really free)
  • 10. ENABLING XDEBUG IN PHP.INI[xdebug]zend_extension = /path/to/xdebug.soxdebug.remote_enable = Onxdebug.remote_autostart = 1xdebug.remote_host = localhostxdebug.remote_port = 9000xdebug.profiler_output_dir = /path/to/xdebug_tracesxdebug.profiler_enable = 1If you use apache with mod_php, you’ll need to restart yourapache process in order for changes to be applied.
  • 11. USEFUL STACK TRACES
  • 12. DEBUGGING DEMO
  • 13. DEBUGGING ALTERNATIVESFirePHP (Ajax debugging)http://firephp.orgVim-debug (Vim plugin)http://jaredforsyth.com/projects/vim-debugDevPHP (Windows IDE)http://devphp.sf.net More listed onKomodo (Cross-platform IDE)http://www.activestate.com/komodo-ide http://xdebug.orgNetbeans (Cross-platform IDE)http://netbeans.orgEclipse PDT (Cross-platform IDE)http://eclipse.org
  • 14. MODULEALTERNATIVESXdebughttp://xdebug.orgZend Debuggerhttp://downloads.zend.com/pdt/server-debugger
  • 15. PROFILING Making stuff fast
  • 16. WHATS TAKING SO LONG?• Overview of script lifetime• Whats taking so long?• What can be improved?• Insight into code operation• Detail inefficiencies
  • 17. MEASURING PERFORMANCE• Preference: siege • siege -c 25 -t 10S http://localhost • 25 concurrent users • 10 second siege• Vary settings based on requirements for expected production site usage
  • 18. REVIEW OUR XDEBUG SETTINGS[xdebug]zend_extension = /path/to/xdebug.soxdebug.remote_enable = Onxdebug.remote_autostart = 1xdebug.remote_host = localhostxdebug.remote_port = 9000xdebug.profiler_output_dir = /path/to/xdebug_tracesxdebug.profiler_enable = 1If you use apache with mod_php, you’ll need to restart yourapache process in order for changes to be applied.
  • 19. ENTER THE PROFILER• Parse debugger traces• Display results that allow you to optimise• Memory usage• Time to execute• Identify bottlenecks easily
  • 20. WHAT DO WE GET TO SEE?
  • 21. PROFILING DEMO
  • 22. PROFILING ALTERNATIVESMacCallGrind (OSX)http://www.maccallgrind.comKCachegrind (Linux)http://kcachegrind.sourceforge.netWebGrindhttp://code.google.com/p/webgrind/WinCacheGrindhttp://sourceforge.net/projects/wincachegrindPHP Quick Profilerhttp://particletree.com/features/php-quick-profiler/
  • 23. PHILOSOPHY•Make it work•Make it work better•Make it fast