MTTimer 1.0

April 14, 2003 - updated February 8, 2006 (Download)

The MTTimer tags allow you to display the time it took for MovableType to build your page, or portions of your page. If your page builds take a long time, the MTTimer tags may help you detect which parts of your page take the longest time to build. They are also useful to fine tune performance when developing plugins.

Modules Used:
Time::HiRes

  • MTTimerStart
    Starts a new timer or restarts and existing timer. The default timer is automatically started when the CGI that is building the page begins executing.
    • name=”timer1”

    • Specifies the name of the timer. The default value is “”, meaning the default timer.
  • MTTimerValue
    Displays the time elapsed since the specified timer was started.
    • name=”timer1”
      Specifies which timer’s value is displayed. The default is “”, or default imer.
    • clock=”real”, “user”, “system”, “exec”, “stats”
      Specifies whether to display total time elapsed (“real”) or time spent executing in user mode (“user”) system mode (“system”) or user and system (“exec”) mode combined. You can also specify “stats” to display all the times combined:
      user    0.83
      sys     0.05
      real    2.53
             34.84%
    • format=”Page built in %.2f seconds” This attribute allows you to change how the time is displayed; the default is ”%.2f”.

Example:
Place the following tag at the bottom of your search template (MovableType/search_templates/default.tmpl) to show how long it took to perform the search:

<MTTimerValue format="Search time: %.2f seconds.">

Example:
The following code uses two timers (“entries” and “entry”) which will display individual and cumulative times for building a list of entries followed by status information about how much time was spent building the page inside the MTEntries tags:

<MTTimerStart name="entries">
<MTEntries>
    <MTTimerStart name="entry">
    ...
    <MTTimerValue name="entry">, <MTTimerValue name="entries">
</MTEntries>
<pre><MTTimerValue name="entries" clock="stats"></pre>