Instrument template compilation

This adds instrumentation to the template compilation. I'm using a custom template resolver to fetch templates from a database, and I'd like to check whether the templates are being cached correctly, or whether they're constantly being recompiled.