I’ve created a quick utility Snippet for MODX Revolution that logs how long it takes to execute a Snippet (or Chunk) you wrap with it. Makes it easy to find out if a particular tag is creating a performance bottleneck in your MODX Resources.

The Executioner Snippet tells you how long a Snippet takes to process

Here is a quick Snippet that allows you to wrap Snippets, as well as Chunks, to see how long it takes them to execute. It can be useful as a site building tool to see just how long specific non-cacheable tags in your site are taking to execute.


Take this sample getResources tag:

[[!getResources? 
    &parents=`4`
    &where=`{"template:IN":[1,2,3]}`
    &sortbyTV=`eventDate`
    &sortdirTV=`ASC`
    &sortby=``
    &tpl=`getResourcesTpl`
]]

When wrapped by Executioner, it would turn into this:

[[!Executioner?
    &tElement=`getResources` 
    &parents=`4` 
    &where=`{"template:IN":[1,2,3]}` 
    &sortbyTV=`eventDate` 
    &sortdirTV=`ASC` 
    &sortby=`` 
    &tpl=`getResourcesTpl`
]]

And you would see output in your error.log that looks like this:

[2010-10-01 13:06:21] (ERROR @ /revo-master/index.php) modSnippet: getResources executed in 0.0524 s

NOTE: I plan to provide support for more tag types in the future, but for now this is really only useful for wrapping Snippets or Chunks. Let me know (preferably in the Gist comments) if you have any ideas to improve or make this more useful.