WordPress Profiler. WP-Tuner Revised

Before talking about any kind of optimization, we should understand, detect and find what exactly should be optimized. Application profilers will do a part of job for us, because they allow you to find bottlenecks e.g. in your PHP script or database queries. Generally, it’s a powerful tool that gives you the ability to analyze PHP code and see which parts of your code are slow and could use a speed boost.
The WP Tuner Revised plugin for WordPress is a comprehensive thing which will, probably, helps to solve many problems related to high time of blog’s page loading, error, plugins slowdown and so on.

It has following features:

  • Collected data is organized in several highly useful tables (which are shown can be selected in options);
  • page generation – shows how page is generated from mark to mark and how resources and time are distributed;
  • database performance – shows which files (WP core, current theme, plugins, etc) make database calls, how many and how fast;
  • database tables – shows which WP tables get queried;
  • query analysis – shows how specific queries work and consume resources.

Original WP Tuner was published long ago by Mr Pete, and latest official version doesn't work with latest WP engine. But it's a nice plugin and we don't want bury it. So we present a Revised version of WP Tuner. It will help blog administrators as well as software developers improve their WordPress blog and plugins performance.

And it perfect for:

  • WordPress site administrators
  • WordPress plugin and theme designers
  • WordPress developers
  • Even for common users

What it does

Plugin attaches itself to WordPress page generation cycle and logs:

  • time spent;
  • CPU load (for Linux server);
  • database queries;
  • memory usage.

Results of logging are displayed at the bottom of each page (even in admin area) with highlighted bottlenecks. All data in a case of security are visible only to administrators.

The key moment of this plugin is a possibility of adding markers to track your own functions.
Markers in result table show statistics up to next marker. Meaning there can be plenty of stuff running in between default checkpoints.
They can be added to WordPress actions:

add_action(‘action', 'wpTuneFilterTime' );

or at any point in code:
if (function_exists(wpTuneMarkTime)) wpTuneMarkTime('mark');

How to profile WordPress performance with WP Tuner Revised

1) Hook any WordPress action
In wptuner.php, you will find a default set of action hooks. You can add as many hooks as you like for other actions. They look like this (just change "admin_footer" to the name of the action you want to measure):
add_action('admin_footer', 'wpTuneFilterTime' );
Each hook adds a line to the WP Tuner performance analysis table, when that action is triggered.

2) Time anything at all in WordPress
WP Tuner contains a function that causes performance analysis for any section of WordPress code. Just use wpTuneMarkTime('My Marker string');
...at the beginning of the code you want analyzed. Add another marker at the end if needed.
For example, suppose you want to know how much time is spent loading each of the plugins you have enabled. Here's how to do it, by adding two simple lines to wp-settings.php:

if (function_exists(wpTuneMarkTime)) wpTuneMarkTime('Load Plugins'); // ** Add THIS line **

if ( get_option('active_plugins') ) {
  $current_plugins = get_option('active_plugins');
  if ( is_array($current_plugins) ) {
    foreach ($current_plugins as $plugin) {
      if (function_exists(wpTuneMarkTime)) wpTuneMarkTime('Plugin: '.$plugin); // ** Add THIS line **
      if ( '' != $plugin && 0 == validate_file($plugin) && file_exists(WP_PLUGIN_DIR . '/' . $plugin) )
        include_once(WP_PLUGIN_DIR . '/' . $plugin);
    }
  }
}

How to install WP Tuner Revised

As any other WordPress plugin: download, unpack, copy to plugin dir and activate it in admin area.

If WP Tuner Revised doesn’t install correctly, please check the admin page for WP Tuner (Settings->WP Tuner). Plugin should indicate the problem.

Note:
current version still show 1 error.

wp-config.php contains WP Tuner markers, but they are after the ABSPATH definition. Please clean up the file and reinstall WP Tuner.

but you can skip it, ‘cuz everything OK.
#2. In any ways, we should not recommend you to use WP Tuner Revised on a live site without backuping data… 🙂
#3 Small drawbacks. Plugin creates wp-config.WPTunerOrig.php in you WP root folder.
#4 Original version can be obtained here
History:

  • 2012-05-06, ver. 0.9.7
    - better css
    - latest WP compatibility
    - bugs removed

Get WP-Tuner Revised (ver. 0.9.7)

If you have any questions, feel free to ask