Practical Performance Profiling

A presentation at WordCamp Norway 2015 in February 2015 in Oslo, Norway by Andrey Savchenko

Slide 1

Slide 1

Slide 2

Slide 2

2 Andrey “Rarst” Savchenko • Rarst.net ♦ WPSE ( s.tk/wp ) • QueryPosts.com • Composer.Rarst.net

Slide 3

Slide 3

200ms interface interactivity boundary

Slide 4

Slide 4

goal 1 10ms resolution

Slide 5

Slide 5

5 Internet is lying to you 1. Enable profiler extension… 2. Load the page to profile… 3. Find the resulting profile file… 4. Launch the profile viewer application… 5. Load the profile file in viewer application… Bullshit.

Slide 6

Slide 6

goal 2 0..2 clicks

Slide 7

Slide 7

7 Low setup, low detail • easy to install • minimal requirements • primarily totals information

Slide 8

Slide 8

8 var_dump() of profiling printf( '%d queries in %.3f seconds, using %.2fMB memory', get_num_queries(), timer_stop( 0, 3 ), memory_get_peak_usage() / 1024 / 1024 ); // 3 queries in 0.251 seconds, using 4.42MB memory

Slide 9

Slide 9

9 Symfony Stopwatch $stopwatch = new Stopwatch(); $stopwatch->start( 'eventName' ); // some code goes here $event = $stopwatch->stop( 'eventName' ); echo $event->getDuration(); // 202 echo $event->getmemory(); // 3670016 symfony.com/doc/current/components/stopwatch

Slide 10

Slide 10

Laps • common load stages • database queries • HTTP requests github.com/Rarst/laps

Slide 11

Slide 11

11 High setup, high detail • (relatively) hard to install • require PHP binary extension • highly detailed information

Slide 12

Slide 12

12 XHProf / uprofiler • open source • lightweight • lingua franca format github.com/FriendsOfPHP/uprofiler

Slide 13

Slide 13

13 Blackfire • in beta • hosted service • nice user interface blackfire.io

Slide 14

Slide 14

Slide 15

Slide 15

15 Practical performance profiling • bookmarklet trigger • web viewer Complete in–browser workflow.

Slide 16

Slide 16

16 Hands off, always on • automated data collection • looking for anomalies • in multiple contexts

Slide 17

Slide 17

17 New Relic • involved server setup • collects from many technologies • dumbs it down magnificently newrelic.com

Slide 18

Slide 18

18 WP Performance Profiler • WordPress plugin • pure PHP ( no extension ) • contexts ( front/admin/cron/ajax ) wpperformanceprofiler.interconnectit.com

Slide 19

Slide 19

next monday install Laps

Slide 20

Slide 20

a while later question results

Slide 21

Slide 21

21 Thank you for listening! Questions? @Rarst Rarst.net/slides/profiling Rarst.net/slides/profiling/code