Timing templates with a stopwatch

This post briefly introduces some tools for getting accurate estimates of running times for publishing pages when optimizing templates. There are certainly better ways to measure page publishing time than with a stopwatch!

“ Times flies like an arrow. ”

A while back, I was working with my coworkers to speed up publishing times of pages for one of our clients. Our approach was to rework page templates to be more efficient, as there were many sluggish aspects to existing page templates in use. Some of the techniques we ended up using are discussed here.

Initially, we were looking at speeding up pages run through Template Builder, but quickly realized that this is not necessarily an accurate representation of publishing times. So we switched focus directly to publishing, instead of previewing pages or running them through Template Builder.

To get some quick readings, we started working with a stopwatch and recorded start and end times of multiple runs of various templates before and after supposed improvements. However, the accuracy of this method proved shaky, since being off by even one second could really mess up the analysis. An average of even one second of improvement would be significant, say, on a page that takes 20 seconds to publish (for a 5% decrease).

So we decided to whip up some C# fragments to replace our stopwatch. Here you can find a couple C# code snippets that you can add to the start and end of your page templates to append an accurate reading of the publishing time of a your page as an XML/HTML comment. Then, if there really is a one second increase, you should be able to detect it!

capture

One thought on “Timing templates with a stopwatch

  1. Also consider ensuring your tests are as consistent as can be and first confirm there are no specific scheduled (or manually started) tasks running on the machine that may impact its performance (e.g. backup)

    Considering Rendering as part of the overall Publishing process, remember that if you want to see the different stages of the Publishing Process (as opposed just to rendering) you can select to ‘view the transaction’ from an item in the publish queue to assess if there’s an issue with a specific step in the process (Prepare Transport, Transport, Prepare Deployment, Deployment and Committing Deployment. Bear in mind this aspect can be impacted by other users publishing at the same time (also check someone didn’t slip in some scheduled items if you go for a simple ‘out of hours’ approach).

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>