Using regex pattern match in xhprof ignore function

289 Views Asked by At

I am trying to profile a codeigniter application with xhprof. I am getting the report like following...

this is the report of a particular CI controller

Now I am trying to ignore some function during xhprof report generation. For that what I did is like following....

$ignore = array(
    '???_op',
    '???_op@1',
    '???_op@2',
    '???_op@3',
    '???_op@4',
    '???_op@5'
);
xhprof_enable(XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY, array('ignored_functions' => $ignore));

Now if I want to ignore all the CI related functions (i.e the functions starting like CI_*) seems like I have to insert them one by one in the array.

Is there any way where I can pattern match with regex and ignore functions according to my requirement?

1

There are 1 best solutions below

0
On

Unfortunately, PHP's xhprof_enable() does not support regex patterns in the ignored_functions element of the options parameter.

I reckon the simplest way to manually generate the blacklist would be to copy-paste the rendered output from the function into your favorite IDE.

Once the text is in your IDE use the regex find/replace functionality to isolate your desired function names such as:

^(?:\?{3}_op|CI_)\S*

Then just copy the matches into your blacklist array.