Andy Lester > Template-Timer-1.01_02 > Template::Timer



Annotate this POD


Open  1
View/Report Bugs
Module Version: 1.01_02   Source  


Template::Timer - Rudimentary profiling for Template Toolkit


Version 1.01_02


Template::Timer provides inline timings of the template processing througout your code. It's an overridden version of Template::Context that wraps the process() and include() methods.

Using Template::Timer is simple.

    use Template::Timer;

    my %config = ( # Whatever your config is
        INCLUDE_PATH    => '/my/template/path',
        COMPILE_EXT     => '.ttc',
        COMPILE_DIR     => '/tmp/tt',

    if ( $development_mode ) {
        $config{ CONTEXT } = Template::Timer->new( %config );

    my $template = Template->new( \%config );

Now when you process templates, HTML comments will get embedded in your output, which you can easily grep for. The nesting level is also shown.

    <!-- SUMMARY
    L1      0.000             P page/search/display.ttml
    L2      0.189              I element/framework/
    L3      0.206               P element/framework/
    L4      0.571                I element/framework/
    L5      0.585                 P element/framework/
    L5      2.318      1.733      P element/framework/
    L4      2.332      1.761     I element/framework/
    L4      2.348                I element/framework/

    L4    378.117      0.439     I element/framework/content/line-item/
    L3    379.055    221.078    P element/framework/content/
    L2    379.099    221.131   I element/framework/content/
    L2    379.310              I element/atom/
    L3    379.321               P element/atom/
    L3    381.038      1.717    P element/atom/
    L2    381.050      1.740   I element/atom/
    L2    381.061              I element/framework/
    L3    381.068               P element/framework/
    L4    381.350                I element/framework/
    L5    381.361                 P element/framework/
    L5    382.988      1.627      P element/framework/
    L4    383.001      1.651     I element/framework/
    L4    383.015                I element/framework/
    L5    383.022                 P element/framework/
    L5    383.320      0.298      P element/framework/
    L4    383.331      0.316     I element/framework/
    L3    383.369      2.301    P element/framework/
    L2    383.377      2.316   I element/framework/
    L1    387.852    387.852  P page/search/display.ttml

Note that since INCLUDE is a wrapper around PROCESS, calls to INCLUDEs will be doubled up, and slightly longer than the PROCESS call.


Andy Lester, <andy at>


Please report any bugs or feature requests to bug-template-timer at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


Thanks to Randal Schwartz, Bill Moseley, and to Gavin Estey for the original code.


Copyright 2005-2013 Andy Lester.

This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License v2.0.

See or the file that comes with the ack distribution.

syntax highlighting: