![]() Module_invoke_all ( ) is taking a LONG time to execute (nearly 25 seconds). We can clearly tell, now that we’ve focussed on just the top-level calls, that If you look at the code that I executed you’ll see calls toĬache_clear_all ( ) (which is in a loop). What you’re looking at is the output when you collapse everything down to just the top-level function calls. So, how can you possibly tell what function calls really took “too much” time? In order to do that you need to be able to view function calls in terms of their hierarchy (so that you can see which parent’s children took too long to execute). What if you have a thousand function calls that all take up a small chunk of time? Well, it adds up. In the example above everything was called and executed very quickly. It’s the time index and it is useful in determining how long a function took to execute. Here’s what the output looks like in plain text: I needed a way to quickly identify what function calls were “slowing things down.” I found a few tools on github that aimed to make it easier to browse these files, but they weren’t really what I was looking for. The information was there, but how would I comb through it? I opened the file in Vim and wasn’t surprised to see more than 400,000 lines. Here’s the code I executed (via the “execute php code” provided by the Drupal devel module):Īfter running that, I was happy to see a mysite_cache_clear.xt file in my home directory. It took 2.5 minutes to open the file, but it worked perfectly once it opened. As an aside I have successfully parsed a file with 3,013,007 lines using the methods outlined here. Xdebug_stop_trace ( ) instead of just enabling auto trace in my php configuration. In my particular case, I wanted to see why a specific function call (or really a few lines in a Drupal module file) was taking so long to execute. You can see my recommended settings at the bottom of this page, and here’s a good resource on the subject: Having Xdebug trace your function calls is simple enough, and well-documented across the web. In the default traces those two elements are not available. The function traces can optionally also show the values of variables passed to the functions and methods, and also return values. Those so-called “function traces” can be a help for when you are new to an application or when you are trying to figure out what exactly is going on when your application is running. Xdebug allows you to log all function calls, including parameters and return values to a file in different formats. Here’s how Xdebug describes function tracing: Using Xdebug’s trace functionality made this task pretty simple. Recently I needed to find out why a function call was taking so long to execute. I’ve been relying on Xdebug quite a lot in recent years to step through PHP code, analyze stacktraces, inspect variables, profile applications, and more.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |