The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Template::Timer - Rudimentary profiling for Template Toolkit

VERSION

Version 1.01_02

SYNOPSIS

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/page-start.tt
    L3      0.206               P element/framework/page-start.tt
    L4      0.571                I element/framework/preface.tt
    L5      0.585                 P element/framework/preface.tt
    L5      2.318      1.733      P element/framework/preface.tt
    L4      2.332      1.761     I element/framework/preface.tt
    L4      2.348                I element/framework/header.tt

    L4    378.117      0.439     I element/framework/content/line-item/paging.tt
    L3    379.055    221.078    P element/framework/content/line-items.tt
    L2    379.099    221.131   I element/framework/content/line-items.tt
    L2    379.310              I element/atom/inplace-edit-mynotes.tt
    L3    379.321               P element/atom/inplace-edit-mynotes.tt
    L3    381.038      1.717    P element/atom/inplace-edit-mynotes.tt
    L2    381.050      1.740   I element/atom/inplace-edit-mynotes.tt
    L2    381.061              I element/framework/page-end.tt
    L3    381.068               P element/framework/page-end.tt
    L4    381.350                I element/framework/footer.tt
    L5    381.361                 P element/framework/footer.tt
    L5    382.988      1.627      P element/framework/footer.tt
    L4    383.001      1.651     I element/framework/footer.tt
    L4    383.015                I element/framework/epilogue.tt
    L5    383.022                 P element/framework/epilogue.tt
    L5    383.320      0.298      P element/framework/epilogue.tt
    L4    383.331      0.316     I element/framework/epilogue.tt
    L3    383.369      2.301    P element/framework/page-end.tt
    L2    383.377      2.316   I element/framework/page-end.tt
    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.

AUTHOR

Andy Lester, <andy at petdance.com>

BUGS

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

ACKNOWLEDGEMENTS

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

COPYRIGHT & LICENSE

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 http://www.perlfoundation.org/artistic_license_2_0 or the LICENSE.md file that comes with the ack distribution.