Tools for optimising your templates [11.11.2008]
I've just checked in a couple of new methods that might help you figure out the bottlenecks that are slowing down the rendering of your templates.
They are:
bench_marker— takes a "label" argument describing this point in the code. In the log, displays the time since the start of the request that this point was reached.bench_measure— takes a "label" argument and block of code. Surrounds the block with bench_marker logging.
You can pass a few flags to bench_measure — :skip, which does not execute the block at all, and :echo, which returns the string result of the block rather than concatenating it to the template output (and is therefore only really useful in helpers).
bench_marker takes a hash of options, although only one option is currently checked — :prefix, which lets you change the text that precedes the timestamp in the logs.
Note: like most logging, benchmarking only displays in development logs.