Slide 1

Slide 1 text

Robert Basic ~ phpbenelux17 Code profiling with Xdebug and KCachegrind Robert Basic https://robertbasic.com/ @robertbasic

Slide 2

Slide 2 text

Robert Basic ~ phpbenelux17 Tools of the trade Xdebug ● Not just for debugging KCachegrind ● Visualizing profiling data

Slide 3

Slide 3 text

Robert Basic ~ phpbenelux17 What’s the fastest code?

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

Robert Basic ~ phpbenelux17 Number of calls

Slide 6

Slide 6 text

Robert Basic ~ phpbenelux17 Who’s to blame?

Slide 7

Slide 7 text

Robert Basic ~ phpbenelux17 Which was called by another method

Slide 8

Slide 8 text

Robert Basic ~ phpbenelux17 Which was called by another method

Slide 9

Slide 9 text

Robert Basic ~ phpbenelux17 So many callers!

Slide 10

Slide 10 text

Robert Basic ~ phpbenelux17 A graph to see it

Slide 11

Slide 11 text

Robert Basic ~ phpbenelux17 Context to understand it

Slide 12

Slide 12 text

Robert Basic ~ phpbenelux17 Fix it This is really up to you

Slide 13

Slide 13 text

Robert Basic ~ phpbenelux17 Tips for fixing performance issues ● Biggest impact, least effort ● Profile after every change ● Avoid over-optimizing ● Learn to EXPLAIN

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

Robert Basic ~ phpbenelux17 Other tools ● WinCacheGrind, Webgrind ● XHProf ● Blackfire.io

Slide 16

Slide 16 text

Robert Basic ~ phpbenelux17 Thanks! Questions?