Better WordPress profiling with xhprof and $ignoredFunctions

Are you profiling your WordPress-based web application/site with xhprof? Go read my other article about how to install and configure xhprof profiler with WordPress. Even if you are already familiar with xhprof, there is a small but important problem: the profiling results are unnecessary bloated.

Figure 1:  Bloated Expensive Calls Chart
Figure 1: Bloated Expensive Calls Chart
Figure 2:  Bloated table
Figure 2: Bloated table

See what I mean?

What are these?

  • ()main
  • op_???
  • call_user_func_array
  • do_action
  • etc

Is it really important for us to know that a function going by name do_action takes 800 milliseconds of a site’s loading time? What about call_user_func_array? Well, no, not even a little bit. These general WordPress/PHP functions tell us nothing valuable.

Put them on the $ignoredFunctions list

The solution is straightforward. Open the xhprof’s config.php file and look for $ignoredFunctions variable. It was commented out in my case. Uncomment it and add names of the functions you want to hide from the chart and table there. Fore example:

$ignoredFunctions = array(
    /**
     * Ignored functions for WordPress sites
     */
    'call_user_func',
    'call_user_func_array',
    'socket_select',
    '???_op',
    'op@1_???',
    'op@2_???',
    'op@3_???',
    'op@4_???',
    'op@5_???',
    '()main',
    'do_action',
    'apply_filters'
);

Now we get a much nicer overview of what is slowing our site down!

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: