A presentation at WordCamp Norway 2015 in
February 2015 in
Oslo, Norway by
Andrey “Rarst” Savchenko • Rarst.net ♦ WPSE ( s.tk/wp ) • QueryPosts.com • Composer.Rarst.net
200ms interface interactivity boundary
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…
Low setup, low detail • easy to install • minimal requirements • primarily totals information
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
Symfony Stopwatch $stopwatch = new Stopwatch(); $stopwatch->start( 'eventName' ); // some code goes here $event = $stopwatch->stop( 'eventName' ); echo $event->getDuration(); // 202 echo $event->getmemory(); // 3670016
Laps • common load stages • database queries • HTTP requests github.com/Rarst/laps
High setup, high detail • (relatively) hard to install • require PHP binary extension • highly detailed information
XHProf / uprofiler • open source • lightweight • lingua franca format github.com/FriendsOfPHP/uprofiler
Blackfire • in beta • hosted service • nice user interface blackfire.io
Practical performance profiling • bookmarklet trigger • web viewer Complete in–browser workflow.
Hands off, always on • automated data collection • looking for anomalies • in multiple contexts
New Relic • involved server setup • collects from many technologies • dumbs it down magnificently newrelic.com
WP Performance Profiler • WordPress plugin • pure PHP ( no extension ) • contexts ( front/admin/cron/ajax ) wpperformanceprofiler.interconnectit.com
a while later
Thank you for listening! Questions? @Rarst Rarst.net/slides/profiling Rarst.net/slides/profiling/code
View Practical Performance Profiling on Notist.
The tools for PHP performance profiling (from basic to advanced) and how to build actionable and beneficial workflows out of them.
The following resources were mentioned during the presentation or are useful additional information.
Original slides for the talk.
Laps is a plugin that shows performance information about WordPress page load.
It provides a visual summary in toolbar that is quick and easy to inspect.
PHP performance profiler.
The following code examples from the presentation can be tried out live.