I maintain a number of WordPress plugins, and they get used on all manner of WordPress sites. One of my more popular plugins is the WooCommerce Google Product Feed extension. This queries all products, applies some logic, and user-definable mappings and outputs an XML feed that Google will import into their product ad system.
On small stores, this is pretty straightforward, but on larger stores, the effort to query all products (including all individual variations of products) can be significant.
I’ve recently been doing some work on performance-tuning the plugin. I started out with some really simple performance tracking outputting total time and memory usage at the end of the XML document. There were some quick wins as a result of that, but it didn’t really give me a feel for what was going on, or any big gains.
I’m normally a big fan of the Query Monitor plugin for reviewing what queries are run to generate a page, however in this instance it doesn’t help since there is no HTML output to the page for Query Monitor to add its results to. I needed something that wasn’t tied to logging its output to the generated page. I finally settled on Time-Stack by Joe Hoyle.
There are actually two things you need to get up and running – the timestack “app” (repo linked above), and the WordPress plugin that logs the data. Once you’ve got the app installed, and the WordPress plugin activated, then every request will be tracked, and visible in the app:
You get to see the total runtime, and memory usage, but more importantly you can drill into sections of the page request to see further information. You can right down to the actual queries being run and see exactly what’s going on. You can even instrument your code to markup useful sections for your profiling.
How did I get on? I’ll let the evidence speak for itself …
— Lee Willis (@leewillis77) August 25, 2016
Probably not for every site, or every occasion, but an awesome tool to have in the locker – thanks Joe!