Code profiling with Xdebug and Kcachegrind

Code profiling with Xdebug and Kcachegrind

Slides for an uncon talk I gave at phpbnl17

6d9ae403ee630c0e51ec79105a3b7af1?s=128

robertbasic

January 28, 2017
Tweet

Transcript

  1. Robert Basic ~ phpbenelux17 Code profiling with Xdebug and KCachegrind

    Robert Basic https://robertbasic.com/ @robertbasic
  2. Robert Basic ~ phpbenelux17 Tools of the trade Xdebug •

    Not just for debugging KCachegrind • Visualizing profiling data
  3. Robert Basic ~ phpbenelux17 What’s the fastest code?

  4. Robert Basic ~ phpbenelux17 The code that’s not called!

  5. Robert Basic ~ phpbenelux17 Number of calls

  6. Robert Basic ~ phpbenelux17 Who’s to blame?

  7. Robert Basic ~ phpbenelux17 Which was called by another method

  8. Robert Basic ~ phpbenelux17 Which was called by another method

  9. Robert Basic ~ phpbenelux17 So many callers!

  10. Robert Basic ~ phpbenelux17 A graph to see it

  11. Robert Basic ~ phpbenelux17 Context to understand it

  12. Robert Basic ~ phpbenelux17 Fix it This is really up

    to you
  13. Robert Basic ~ phpbenelux17 Tips for fixing performance issues •

    Biggest impact, least effort • Profile after every change • Avoid over-optimizing • Learn to EXPLAIN
  14. Robert Basic ~ phpbenelux17 Tips for using Xdebug and KCachegrind

    • Xdebug – xdebug.profiler_output_dir – xdebug.profiler_output_name – cachegrind.out.%t.%R – Xdebug lies! • KCachegrind – Install graphviz – Use % relative – Turn on Cycle detection – Settings > Configure KCachegrind > Annotations > Add source folder
  15. Robert Basic ~ phpbenelux17 Other tools • WinCacheGrind, Webgrind •

    XHProf • Blackfire.io
  16. Robert Basic ~ phpbenelux17 Thanks! Questions?